Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
JAmbrose69
Frequent Visitor

Cleaning Data In PowerBi

I have trouble cleaning data in PowerBi. So I would like to know two things. The first is how do I clean the data example below. The second question, would there be any classes or any resources to help me clean data properly as the example is not as complex as some of the items in my queue. 

 

For the example below I have watched a video from MS PowerBi on "Clean data to include in a report" but it did not go deep enough to help me. I need to display the entity, measure, the actual data, all by date. Basically a trend over time for this specfic example. 

 

Example:

DateMeasureEntity1Entity2Entity3Entity4Average 
9/7/22measure1.99

.98

.98.95.975 
9/7/22measure211111 
9/7/22measure3.95.95.95.95.95 
9/14/22measure1.9.9.9.9.9 
9/14/22measure201.9.5.6 
9/14/22measure3.3.7.7.9.65 
9/21/22measure211111 
9/21/22measure3.9.9.9.9.9 

 

 

Please let me know if you have any additonal questions

 

Thanks in advance

1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @JAmbrose69 ,

 

For the data that you present I believe that you need to unpivot your data. On Power Query select the columns Date and measure and then on Transform Select Unpivot Other columns:

MFelix_0-1675526560654.png

 

You will get a table with 4 columns:

  • Date
  • Measure
  • Attribute (entity names)
  • Value

Rename the Attribute column and you should be all set:

MFelix_1-1675526616777.png

Now you can do a filter on measure or create the value based on entity:

MFelix_2-1675526726882.png

 

MFelix_3-1675526774679.png

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

2 REPLIES 2
lbendlin
Super User
Super User

There is a basic rule - Power BI wants narrow tables.  Your sample data is a prime example of what not to do - using wide tables.  So the most frequent cleaning technique is "unpivoting"

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WstQ31zcyUtJRyk1NLC4tSjUEMvUsLcGkBRJpqhSrg6kaxDREwdhUGUNNwCQhqg1NsDgBncCqFMQ0gNoNUYjDTLATwIQ5nICZaWRIlJ/QlBljd2UsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, Measure = _t, Entity1 = _t, Entity2 = _t, Entity3 = _t, Entity4 = _t]),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(Source, {"Date", "Measure"}, "Entity", "Value"),
    #"Changed Type" = Table.TransformColumnTypes(#"Unpivoted Other Columns",{{"Date", type date}, {"Value", type number}})
in
    #"Changed Type"

lbendlin_1-1675532969143.png

Note that I also dropped the Average column - that can be computed in Power BI.

 

MFelix
Super User
Super User

Hi @JAmbrose69 ,

 

For the data that you present I believe that you need to unpivot your data. On Power Query select the columns Date and measure and then on Transform Select Unpivot Other columns:

MFelix_0-1675526560654.png

 

You will get a table with 4 columns:

  • Date
  • Measure
  • Attribute (entity names)
  • Value

Rename the Attribute column and you should be all set:

MFelix_1-1675526616777.png

Now you can do a filter on measure or create the value based on entity:

MFelix_2-1675526726882.png

 

MFelix_3-1675526774679.png

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

Check out the October 2024 Power BI update to learn about new features.

October NL Carousel

Fabric Community Update - October 2024

Find out what's new and trending in the Fabric Community.