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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
Anonymous
Not applicable

Model Data from Input Table

Hello,

 

I am looking for a resource on how to edit data in excel so it is easy to work with in Power BI

My organisation have an input table that looks somewhat like this:

CategorySubCategoryBaseTarget  janfebmaraprmayjun
            
Cat 1           
 SubCat 10100  0002568100
 SubCat20100  1035608590100
 SubCat30100  20406080100100
            
Cat 2           
 SubCat10100  000000
 SubCat20100  51525354555
 SubCat30100  153045607590

 

Good for people who are going to input the data but less good for power bi.

I was thinking that it is better to have the data like this:

CategorySubCategoryBaseTargetMonthValue

Cat 1

SubCat10100jan0
Cat 1SubCat20100jan10
Cat 1SubCat30100jan20
Cat 2SubCat10100jan0
Cat 2SubCat20100jan5
Cat 2SubCat30100jan15
..................

 

Do any of you know a guide on youtube on how to do it in excel or power bi?

Or telling me is obviously okay too.

 

Thanks!

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

@Anonymous Easiest thing to do would be on your import to Power BI, select your month columns and then unpivot them.

Greg_Deckler_0-1650457599576.png

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

3 REPLIES 3
Vijay_A_Verma
Most Valuable Professional
Most Valuable Professional

Below is M code in Power Query. Power Query will have to be used to give a shape to your data.

The Excel file used is uploaded to https://1drv.ms/x/s!Akd5y6ruJhvhuV3qyP0JmyTmxaTo?e=Y9rige 

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Removed Columns" = Table.RemoveColumns(Source,{"Column1", "Column2"}),
    #"Added Custom1" = Table.AddColumn(#"Removed Columns", "AllNull", each List.NonNullCount(Record.ToList(_))=0),
    #"Filtered Rows1" = Table.SelectRows(#"Added Custom1", each ([AllNull] = false)),
    #"Removed Columns2" = Table.RemoveColumns(#"Filtered Rows1",{"AllNull"}),
    #"Filled Down" = Table.FillDown(#"Removed Columns2",{"Category"}),
    #"Filtered Rows" = Table.SelectRows(#"Filled Down", each [SubCategory] <> null),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Filtered Rows", {"Target", "Base", "SubCategory", "Category"}, "Attribute", "Value"),
    #"Added Custom" = Table.AddColumn(#"Unpivoted Other Columns", "Date", each Date.From("1"&[Attribute])),
    #"Sorted Rows" = Table.Sort(#"Added Custom",{{"Date", Order.Ascending}, {"Category", Order.Ascending}, {"SubCategory", Order.Ascending}}),
    #"Removed Columns1" = Table.RemoveColumns(#"Sorted Rows",{"Date"})
in
    #"Removed Columns1"

 

Greg_Deckler
Community Champion
Community Champion

@Anonymous Easiest thing to do would be on your import to Power BI, select your month columns and then unpivot them.

Greg_Deckler_0-1650457599576.png

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

@Greg_Deckler Thank you, this was exactly what I was looking for!

Helpful resources

Announcements
FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.