Power Query - Pivoting Stacked Data

Поділитися
Вставка
  • Опубліковано 3 гру 2024

КОМЕНТАРІ • 42

  • @IvanCortinas_ES
    @IvanCortinas_ES 3 дні тому

    Absolutely pro-solutions, as always. Thank you for sharing them!!!

    • @bcti-bcti
      @bcti-bcti  3 дні тому

      @@IvanCortinas_ES My pleasure. Thanks for watching!

  • @kkravch
    @kkravch 3 дні тому

    Thank you, Professor. Great explanation.

    • @bcti-bcti
      @bcti-bcti  3 дні тому

      @@kkravch Thank you! Now go out and conquer the world.

  • @iankr
    @iankr 4 дні тому +2

    Excellent techniques, clearly explained. Many thanks.

    • @bcti-bcti
      @bcti-bcti  4 дні тому +1

      @@iankr Thank you. Could you tell I have a head cold?

  • @adamtabor6754
    @adamtabor6754 4 дні тому

    Excellent solution and explanation.

    • @bcti-bcti
      @bcti-bcti  4 дні тому

      Thank you. Many viewers are contributing some AMAZING alternate solutions. Check out some of the great ideas in the comments.

  • @alperkins66
    @alperkins66 2 дні тому

    While the right click to import data as a Table works beautifully. I find having a Quick Access icon with Table import is my best option for bringing in Tables. Thank you for your outstanding work on Power Query, etc.

    • @bcti-bcti
      @bcti-bcti  2 дні тому

      I agree 100% I love customizing my QAT. Have you seen my video on the "Complete Guide to the QAT"? Check it out; I bet there are some tricks you may not have known. Cheers.
      ua-cam.com/video/GEv7_AHtv-w/v-deo.html

  • @scotolivera8207
    @scotolivera8207 4 дні тому +2

    helpful, wraprows also could be used as well here

    • @bcti-bcti
      @bcti-bcti  4 дні тому

      Yes; many viewers are contributing some AMAZING alternate solutions. Check out some of the other replies for ideas similar to your own. Thanks for watching.

  • @chrism9037
    @chrism9037 4 дні тому

    Excellent, thank you!

    • @bcti-bcti
      @bcti-bcti  4 дні тому

      Thank you very much. We greatly appreciate your support and engagement.

  • @Bhavik_Khatri
    @Bhavik_Khatri 4 дні тому

    Solution 2 is quite impressive. I appreciate you sharing it.

    • @bcti-bcti
      @bcti-bcti  4 дні тому

      @@Bhavik_Khatri My pleasure. Thanks for watching.

  • @jawadahmadehssan6251
    @jawadahmadehssan6251 4 дні тому

    Thank you for the great content as always

    • @bcti-bcti
      @bcti-bcti  4 дні тому

      My pleasure! Thanks for watching.

  • @arnyanderson4955
    @arnyanderson4955 4 дні тому

    Really waiting your new tutorials, always found amazing and excellent and yes applicable to working world
    Hats off

    • @bcti-bcti
      @bcti-bcti  4 дні тому

      @@arnyanderson4955 Thank you! It’s nice to feel appreciated. Cheers!

  • @RichardJones73
    @RichardJones73 4 дні тому

    Thanks for the handy little tips, especially the non conversion of data to a table by naming the range

    • @bcti-bcti
      @bcti-bcti  4 дні тому

      I love that trick! I wish that was a behavior we could turn off in the PQ settings. Thanks for watching.

  • @tinhoyhu
    @tinhoyhu 4 дні тому +4

    =wraprows(filter(sales, sales""), 4)
    Safer, in case of empty cells in data:
    =TAKE(WRAPROWS(SALES, 5),,4)

    • @bcti-bcti
      @bcti-bcti  4 дні тому +1

      That is an EXCELLENT way of solving the problem using Dynamic Array functions. I love DA functions!!! When I use DA function for this, I am not getting the rank for the first entry ("McDonald's") to display. What about you? This is odd. Trying to figure out why. Thanks for your great solution!!!

    • @bcti-bcti
      @bcti-bcti  4 дні тому

      When I recreated the data in a new file, I didn't have the problem of the missing first rank. But no matter where I put that formula in the download file, the first rank is blank. "1" show up in the formula audit trail, but not in the displayed output. This is very odd, indeed.

    • @tinhoyhu
      @tinhoyhu 4 дні тому +1

      It works in the download file for me. This is with Excel on Android.

    • @ursula9875
      @ursula9875 4 дні тому

      :)

    • @tinhoyhu
      @tinhoyhu 4 дні тому

      @@bcti-bcti yes, the dynamic array functions have really changed the way I tackle problems in Excel. Each tool has its strengths, so it'd be cool if PQ could evaluate excel functions, like how Excel could call python to return a dataset.
      For example, EXCEL(table_reference, "=TAKE(WRAPROWS (table_reference, 5),,4)").
      Would probably be a nightmare on query folding though.

  • @ismaelkourouma5558
    @ismaelkourouma5558 4 дні тому

    Excellent.
    Do you use Camtasia for your videos?

    • @bcti-bcti
      @bcti-bcti  4 дні тому

      @@ismaelkourouma5558 Yes. Is it that obvious? 🤣

  • @billhladik406
    @billhladik406 4 дні тому

    Always good to know PQ stuff, but easier for this example:
    =INDEX(A1:A254,SEQUENCE(ROWS(A1:A254)/5,5))

    • @bcti-bcti
      @bcti-bcti  4 дні тому

      I like your thinking! I've made an adjustment to the formula to discard the column of zeroes (blank rows in source).
      =DROP(INDEX(A1:A254,SEQUENCE(ROWS(A1:A254)/5,5)),,-1)
      If you're using Dynamic Array functions (and I assume you are since you are using the SEQUENCE function), a shorter version offered by another viewer is:
      =TAKE(WRAPROWS(Sales, 5),,4)
      Thanks for watching and contributing. It's always great to see alternate solutions. Cheers!

  • @DAXifiedSatish
    @DAXifiedSatish День тому

    Though wrap rows is simple way to do this, i want to do this with my favorite Reduce Function
    =LET(TheMagicNumber,5,Data,A1:A254,
    REDUCE(TOROW(TAKE(Data,TheMagicNumber),1),
    SEQUENCE(ROWS(Data)/TheMagicNumber,1,TheMagicNumber,TheMagicNumber),
    LAMBDA(acc,curr,VSTACK(acc,TOROW(OFFSET(A1,curr,0,TheMagicNumber,1),1)))))

    • @bcti-bcti
      @bcti-bcti  День тому +1

      I always enjoy seeing how other people solve the same problem. Great job!

  • @Michael_Alaska
    @Michael_Alaska 3 дні тому

    Overly complicated. No need for Power Query. Use formula =WRAPROWS(A:A,5) and viola!

    • @bcti-bcti
      @bcti-bcti  3 дні тому

      Agreed! But for those who do not have access to Dynamic Array functions, Power Query is an option. Plus, this video also served as a way to demonstrate a variety of Power Query features for use in other situations.
      Sidenote: you would still need to filter out the resulting 5th column of zeroes, as well as the other 209K+ rows at the bottom of the output.
      Thanks for your ideas and time to watch. Cheers.

  • @boissierepascal5755
    @boissierepascal5755 4 дні тому +2

    Hi ! Thank you for your work. A shorter way with M code.
    let
    Source = Excel.CurrentWorkbook(){[Name="Sales"]}[Content][Column1],
    TransfTable = Table.FromRows(List.Split(List.RemoveNulls(Source),4),{"Rank","Company","Category","Sales"}),
    Currency= Table.TransformColumnTypes(TransfTable,{{"Sales", Currency.Type}})
    in
    Currency

    • @bcti-bcti
      @bcti-bcti  4 дні тому +1

      I LOVE IT!!!! That is fantastic! I have split your single step into separate steps so it's easier to understand for beginners. Thank you for a great solution. Different tactics are ALWAYS appreciated.
      let
      Source = Excel.CurrentWorkbook(){[Name = "Sales"]}[Content][Column1],
      #"Remove Nulls" = List.RemoveNulls(Source),
      #"Records to Lists" = List.Split(#"Remove Nulls", 4),
      #"Lists to Records" = Table.FromRows(
      #"Records to Lists",
      {"Rank", "Company", "Category", "Sales"}
      ),
      #"Set Data Types" = Table.TransformColumnTypes(
      #"Lists to Records",
      {{"Rank", Int64.Type}, {"Company", type text}, {"Category", type text}, {"Sales", Int64.Type}}
      )
      in
      #"Set Data Types"

    • @boissierepascal5755
      @boissierepascal5755 4 дні тому

      @bcti-bcti 👏🏼👏🏼👏🏼