Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hello team,
Looking for help transforming the data in this file.
It should be a simple excercise but I am missing a couple of steps.
Appreciate you help.
GR.
Solved! Go to Solution.
Hi,
In power query:
If I answered your question, please mark my post as solution, Appreciate your Kudos 👍
No problem, happy to help 🙂
@DOLEARY85 I just ran into some trouble. When I run step 5: Expand the table and only bring through the Category and value columns
Cat1 values for 21.03 (Mar 2021) duplicate when I merge (Table 1 and 2) and Cat2 values for 21.03 (Mar 2021) duplicate when I merge with Table 3. See dup data below in red and blue.
How do I prevent the data from duplicating? Thanks.
Ah yes, the combination of fields to merge on aren't unique.
Add an Index column from the add column ribbon after the unpivoted columns step on each of the tables and then when merging the tables include the Index as one of the matching columns. This should remove duplicates
If I answered your question, please mark my post as solution, Appreciate your Kudos 👍
Here are the steps I am following:
I get a bunch of null when I expand the results from merging the New Query and table 3. I believe the reason is that Table 1 and 2 has 4 attiributes but Table 3 has 3 attribute only. So, for example the index does not correspond to the same quarters when comparing Table 3 with Table 1 and 2. Should adding a step to create a dummy attribute work? or is there a different solution?
Thanks, okay i see the problem, Attribute & Multiple join fine but ratio only has 2 columns so it's not going to create the same amount of rows when unpivotted. There needs to be a unique field created after unpivoting to join the rows back.
I'll look at this today and see if i can come up with something.
I've updated the file with something that should work, take a look and let me know.
There will be blanks in the Ratio column as you only have 2 columns instead of 3 as with the other attribute & multiple.
Hope this helps
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bZJLjsMgEESvElnjXdSif3yOkdUsIt/Dxx9o2piQ2VSBZb8uyrzf2y9uz40QXlw94Kvq4wcZNDxsmSCnvqIAbA8DlLMaQjhtp7aTvak2lbRvx3NiS3uPOptxsBUCOVshOjud94gAYmy62awzmzy3dnZOQNqJxYE28MqdOzR2w2acjBqbqixsyx07WxCifLHVD7N2Um52tGbkYss/fWsNM9jqJ5A7t3fixs1KtsRd48Ke+04I6GnjmCIE9Mn2TqhZtNzJOhGc2UvfqX6HnZhB/F8KD7b3nad7wsHYlhvLwp77Lgws1z0ZnQjkT7ZMI9QSI+/ez3H8AQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Widgets = _t, Qtr = _t, #"Maturity Qtr" = _t, Attribute1 = _t, Attribute2 = _t, Attribute3 = _t, Multiple1 = _t, Multiple2 = _t, Multiple3 = _t, Ratio1 = _t, Ratio2 = _t, Ratio3 = _t]),
Unpivoted = Table.UnpivotOtherColumns(Source, {"Widgets", "Qtr", "Maturity Qtr"}, "Attribute", "Value"),
Attribute = List.Transform (List.Select(Table.ToRecords(Unpivoted), each Text.Contains([Attribute],"Attribute")), Record.ToList),
Multiple = List.Transform( List.Select(Table.ToRecords(Unpivoted), each Text.Contains([Attribute],"Multiple")), each Record.ToList(Record.SelectFields(_,{"Attribute","Value"}) )),
Ratio = List.Transform( List.Select(Table.ToRecords(Unpivoted), each Text.Contains([Attribute],"Ratio")), each Record.ToList(Record.SelectFields(_,{"Attribute","Value"}) )),
Combined = Table.FromRows ( List.Transform(List.Zip( {Attribute,Multiple,Ratio}), List.Combine),
List.FirstN(Table.ColumnNames(Source),3)&{"Category","Value$","Category2","ValueX","Category3","Value%"}),
#"Added Index" = Table.AddIndexColumn(Combined, "Index", 0, 1, Int64.Type),
Sorted = Table.Sort(#"Added Index",{{"Category", Order.Ascending}, {"Index", Order.Ascending}}),
FINAL = Table.RemoveColumns(Sorted,{"Index"})
in
FINAL
You can try this as well.
Thanks Jakinta. What the best way to implement this code? is it a copy/paste somewhere in power query OR do I need to follow step by step and excecute each step in power query? Thanks.
Hi,
In power query:
If I answered your question, please mark my post as solution, Appreciate your Kudos 👍
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.