How to use Pivot in Power Query and avoid the errors (PLUS bonus at minute 6)

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

КОМЕНТАРІ • 86

  • @AgulloBernat
    @AgulloBernat Рік тому +2

    awesome

  • @Looii5
    @Looii5 2 місяці тому +1

    The tips are great and so is the guitar music at the end! 🎸

  • @BillSzysz1
    @BillSzysz1 Рік тому +2

    Thanks for great lesson 👍. But i have one small remark.
    If the source table is not sorted by month then the order of the rows in the result table may be incorrect.
    So, i propose add as a first step of query (it doesn't have to be the first step, but for clarity, I like it to be at the beginning)
    MonthsOrder = Table.FromColumns(
    {
    List.Transform(
    List.Dates(#date(1, 1, 15), 12, #duration(30, 0, 0, 0)),
    each Date.ToText(_, "MMM", "en-GB")
    ),
    {1 .. 12}
    },
    {"Months", "Idx"}
    )
    Then the "Merged Queries" step and the following would look like this below
    #"Merged Queries" = Table.NestedJoin( ReadyForMerge, {"Month"}, MonthsOrder2, {"Month"}, "MonthsOrder", JoinKind.LeftOuter ),
    Expanded = Table.ExpandTableColumn( #"Merged Queries", "MonthsOrder", {"Idx"}, {"Idx"}),
    #"Sorted Rows" = Table.Sort( Expanded, {{"Idx", Order.Ascending}, {"Index", Order.Ascending}} ),
    #"Removed Columns" = Table.RemoveColumns(#"Sorted Rows", {"Index", "Idx"})
    in
    #"Removed Columns"
    The advantage of this solution is that we can have the names of the months in any language (just change "en-GB" to, for example, "pl-PL")

  • @annabelgodwin4862
    @annabelgodwin4862 16 днів тому +1

    Thank you so so much! I can’t believe how brilliantly this worked, I’ve been trying to sort this for a while with no luck - and what a lovely bonus tip to include too! Thank you!

    • @AccessAnalytic
      @AccessAnalytic  16 днів тому +1

      You're welcome - I really appreciate you letting me know

    • @annabelgodwin4862
      @annabelgodwin4862 16 днів тому +2

      @@AccessAnalytic Of course! Once again, thank you so much, I knew there had to be some way around it but whatever I tried wasn’t working so it was starting to feel a little hopeless. You have such a calming voice and teaching manner, which is honestly brilliant for those of us who struggle to understand all the ins and outs. I’m very grateful, and I’m sure so many others are too! :)

  • @kebincui
    @kebincui Рік тому +2

    Excellent tip to deal with annoying error in pivoting a column. Thank you Wyn

  • @zahoorsarbandi2982
    @zahoorsarbandi2982 Рік тому +2

    Believe me today I needed it and fortunately I found my solution in this video.. thank you very much sir

  • @krishanphophalia9303
    @krishanphophalia9303 Рік тому +2

    Great tip, Wyn! You always pleasantly surprise us with these weekly tips. ❤

  • @sebastianschick1989
    @sebastianschick1989 6 місяців тому +1

    very helpful, you've saved my day - thanks a lot, and the bonus tip was very helpful as well👍👌😊

  • @MoRo9083
    @MoRo9083 8 місяців тому +1

    Sir, usted no sabe como lo amo en este momento!

  • @abdulsaidmkamara7305
    @abdulsaidmkamara7305 Рік тому +1

    always a pleasure learning from you on Saturday.

  • @TopBam
    @TopBam 8 місяців тому +2

    Very useful! I needed this for a two-column data set as an alternative to my complicated let/drop/reduce/lambda formula.

    • @AccessAnalytic
      @AccessAnalytic  8 місяців тому +1

      I appreciate you taking the time to let me know you found it useful

    • @dougmphilly
      @dougmphilly 5 місяців тому +1

      anything is better than lambda. you hand offv a spreadsheet to anyone with that function all you get is stares.

    • @TopBam
      @TopBam 5 місяців тому +1

      @@dougmphilly I still love LAMBDA! Greatest thing to hit excel since power query came out for Excel 2010. It is a real game changer, just like power query.

    • @dougmphilly
      @dougmphilly 4 місяці тому

      @@TopBam its only intuitive to the most powerful of power users. i tried explaining the function in a shared spreadsheet that went absolutely nowhere.

    • @TopBam
      @TopBam 4 місяці тому

      @@dougmphilly They can learn if they are taught correctly. Lack of competence is problem in every profession. Just because people don't understand it, doesn't mean we should not use it.

  • @rahulkalingeri1206
    @rahulkalingeri1206 2 місяці тому +1

    Wowww.. just what I needed ..thanks a lot 🙂

    • @AccessAnalytic
      @AccessAnalytic  2 місяці тому

      You’re welcome. I appreciate you taking the time to let me know you found it useful

  • @ksowjanya4488
    @ksowjanya4488 Рік тому +1

    Thank you for clear explanation.

  • @entertainmentgalaxy971
    @entertainmentgalaxy971 10 місяців тому +1

    Thanks for an amazing solution. I think you can add helper column in source table to make it simple for sort order.
    =MONTH(DATEVALUE("1-"&[@Month]&"-1900"))

  • @109zxg
    @109zxg 10 місяців тому +1

    Brilliant, exact what I want to learn! Thank you

    • @AccessAnalytic
      @AccessAnalytic  10 місяців тому

      Thanks for letting me know it was useful 😀

  • @shubhabratadey
    @shubhabratadey 11 місяців тому +1

    Nice video. Many thanks

  • @williamarthur4801
    @williamarthur4801 Рік тому +1

    Like the sort trick, and thanks for mentioning about Upper before lower case sorting in previous,
    when I did this I had a jan in wrong order, and if you hadn't mentioned that upper sort first would have spent good while wondering why.

  • @chrism9037
    @chrism9037 Рік тому +1

    Very helpful video, thanks Wyn!

    • @AccessAnalytic
      @AccessAnalytic  Рік тому

      You’re welcome Chris. Thanks for taking the time to leave a kind comment

  • @behzadghah
    @behzadghah Рік тому +1

    grate solution. thank you

  • @BobXu-i7v
    @BobXu-i7v 7 місяців тому +1

    Awesome! Very powerful.

  • @gsbertho
    @gsbertho 11 місяців тому +1

    so simple and so useful !!!

  • @Bhavik_Khatri
    @Bhavik_Khatri Рік тому +2

    Nice tricks

  • @HatemEsmat
    @HatemEsmat 3 місяці тому +1

    Awesome, Thanks a lot❤

  • @tomstrack42
    @tomstrack42 Рік тому +1

    Excellent!

  • @lorenzoladejobi8701
    @lorenzoladejobi8701 Рік тому +1

    Very educative!

  • @cheikhhakim5864
    @cheikhhakim5864 Рік тому +1

    thank you sir

  • @baskis69
    @baskis69 Рік тому +1

    Nice trick... you're a power query wizard¡¡¡ ;)

  • @alexrosen8762
    @alexrosen8762 Рік тому +1

    Super smart and useful

  • @mnowako
    @mnowako Рік тому +1

    Great one, thanks!

  • @juancarlosleytonfernandez9146
    @juancarlosleytonfernandez9146 Рік тому +1

    Genius!!!!!

  • @hassan06ny
    @hassan06ny Рік тому +1

    Thank you!

  • @youssefelghandour3008
    @youssefelghandour3008 Рік тому

    Bahebak❤

  • @nazarkamal8831
    @nazarkamal8831 9 місяців тому +1

    Awesome 👍👍👍

  • @thebhaskarjoshi
    @thebhaskarjoshi Рік тому +1

    Loved it.

  • @mdwasitalinayyar
    @mdwasitalinayyar Рік тому +1

    I concatenate 01-jan-2023 to make a custom column of date.
    The. Sort by that custom date column

  • @pascaljoly5752
    @pascaljoly5752 8 місяців тому

    why did you have to group the data before adding the Index column? does it mean it wouldn't have worked if you'd added the index column without grouping the data?

    • @AccessAnalytic
      @AccessAnalytic  8 місяців тому +1

      It helps keep the records together. So entry 1 for each person appears on same row, then entry 2 etc, otherwise it splits each entry into a unique row

    • @pascaljoly5752
      @pascaljoly5752 8 місяців тому +1

      @@AccessAnalytic makes sense. i have managed to get the same result by creating a function that adds an index column in each sub-table that you get after grouping the data and before expanding the data. at the end of the day, it's pretty much doing the same thing but since i am new to creating functions, it made more sense to me this way to try this way. i could send you what i have done but i don't know how.

    • @pascaljoly5752
      @pascaljoly5752 8 місяців тому

      the function i wrote is basic:
      (MyTable) =>
      let

      #"Added Index" = Table.AddIndexColumn(MyTable, "Index", 1, 1, Int64.Type),
      #"Changed Type3" = Table.TransformColumnTypes(#"Added Index",{{"Index", type number}})
      in
      #"Changed Type3"
      then all i have to do is to invoke it once i've grouped the data. seems to do the job just fine as i get the same result.
      am i missing something?

    • @AccessAnalytic
      @AccessAnalytic  8 місяців тому

      Sounds fine to me

  • @kebincui
    @kebincui Рік тому

    hi Wyn. I am wondering if we just add index to the intial table and then pivot without grouping. Would that also prevent error from popping up? Thanks

    • @AccessAnalytic
      @AccessAnalytic  Рік тому

      Yep, sure does but you get a single row for every entry so it looks pretty messy

    • @kebincui
      @kebincui Рік тому +1

      @@AccessAnalytic Thanks Wyn for your quick clarification❤👍

  • @IMAS7512
    @IMAS7512 Рік тому

    DataFormat.Error: Invalid cell value '#NAME?'. How to solve this error

    • @AccessAnalytic
      @AccessAnalytic  Рік тому

      That sounds like an error in the source excel file.