Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
Hi
I am new to power bi and need some help from you (probably this might be a stupid question)
I have data that is arranged this way:
date | name | buddy |
1/05/2021 | X | Y |
31/05/2021 | A | B |
and want to transform it to:
date | Name |
1/05/2021 | X |
1/05/2021 | Y |
31/05/2021 | A |
31/05/2021 | B |
How can it be done?
regards,
Nausikaa
Hi,
many thanks for your help, did not quite give me the result I was looking for because in my case there were even more columns, but in the end it set me in the right direction and could figure it out myself.
regards,
Nausikaa
Hi @Nausikaa ,
Could you Accept my post as the solution to make the thread closedif it makes sense to you? More people will benefit from it.
Hope to hear from you😀
Best Regards,
Eyelyn Qin
Hi @Nausikaa ,
I have done it in two ways, hope it could help you :
1. In Power Query:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtQ3MNU3MjAyVNJRigDiSKVYnWglY2RhRyB2UoqNBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [date = _t, name = _t, buddy = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"date", type text}, {"name", type text}, {"buddy", type text}}),
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"date"}, "Attribute", "Value"),
#"Removed Columns" = Table.RemoveColumns(#"Unpivoted Other Columns",{"Attribute"}),
#"Renamed Columns" = Table.RenameColumns(#"Removed Columns",{{"Value", "Name"}})
in
#"Renamed Columns"
2. Use DAX to create a calculated table:
Use DAX =
var t1=DISTINCT(SELECTCOLUMNS('Table',"date",[date],"Name",[name]))
var t2=DISTINCT(SELECTCOLUMNS('Table',"date",[date],"Name",[buddy]))
return UNION(t1,t2)
The final output is shown below:
Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@Nausikaa go to transform data and unpivot. Right-click on the date column and then choose unpivot other columns
Check my latest blog post Comparing Selected Client With Other Top N Clients | PeryTUS I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!
⚡Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.⚡
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
User | Count |
---|---|
127 | |
108 | |
99 | |
63 | |
62 |
User | Count |
---|---|
136 | |
113 | |
102 | |
71 | |
60 |