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

Join 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.

Reply
ganeshkandi
New Member

pivot table equation in powerbi

can any body help me with the below ask :

 

appreciated in advance!!

 

Source: 

Datehosp_volumephy_volumeoverall_volume 
2/1/202412341111345 
2/2/2024101585630866466 
2/3/2024223494262664975 
2/4/2024250453050155546 

 

 

Output in powerBI

Date2/1/20242/2/20242/3/20242/4/2024
hosp_volume1234101582234925045
phy_volume111563084262630501
overall_volume1345664666497555546
2 ACCEPTED SOLUTIONS
Syk
Super User
Super User

Select your 3 columns you want as rows > right click > unpivot columns

Syk_0-1715691395568.png

 

Select Date column > Transform > Pivot column > set 'Value' as the values column

Syk_1-1715691455993.png

 

Done!

Syk_2-1715691469940.png

 



View solution in original post

Anonymous
Not applicable

Hi,

Thanks for the solution @Syk  provided, it is great, and i want to offer some supplement for user to refer to.

hello @ganeshkandi , based on the solution @Syk  provided, if you update the date , you can try to click the date column, then select unpivot other columns, then the other steps please follow the step @Syk  provided, then if your date format is right after updating , it will display the data correctly.

vxinruzhumsft_0-1716188992308.png

You can also refer to the following M code in advanced editor in power query.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("PczBDcAwCEPRXThHChjiNrNE2X+NQNX24n958lqCHh2KkCYGf2JW6zFktwL4gdq4s4OuVTLIF/mHkC8zGyBYKOaVT/sA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, hosp_volume = _t, phy_volume = _t, overall_volume = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"hosp_volume", Int64.Type}, {"phy_volume", Int64.Type}, {"overall_volume", Int64.Type}}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Date"}, "Attribute", "Value"),
    #"Pivoted Column" = Table.Pivot(Table.TransformColumnTypes(#"Unpivoted Other Columns", {{"Date", type text}}, "en-US"), List.Distinct(Table.TransformColumnTypes(#"Unpivoted Other Columns", {{"Date", type text}}, "en-US")[Date]), "Date", "Value")
in
    #"Pivoted Column"

 

If the solutions @Syk  and i offered help you, please consider to mark them as a solution.

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

4 REPLIES 4
Syk
Super User
Super User

Select your 3 columns you want as rows > right click > unpivot columns

Syk_0-1715691395568.png

 

Select Date column > Transform > Pivot column > set 'Value' as the values column

Syk_1-1715691455993.png

 

Done!

Syk_2-1715691469940.png

 



@Syk 

We appreciate your time, and please note that these date values are subject to change every day. so more dates will arrive and complement the information.

Should that be the case, will the updated data be incorporated into the table visualization? or will it produce any errors for us?

due to the fact that the column list does not contain the updated date.

Anonymous
Not applicable

Hi,

Thanks for the solution @Syk  provided, it is great, and i want to offer some supplement for user to refer to.

hello @ganeshkandi , based on the solution @Syk  provided, if you update the date , you can try to click the date column, then select unpivot other columns, then the other steps please follow the step @Syk  provided, then if your date format is right after updating , it will display the data correctly.

vxinruzhumsft_0-1716188992308.png

You can also refer to the following M code in advanced editor in power query.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("PczBDcAwCEPRXThHChjiNrNE2X+NQNX24n958lqCHh2KkCYGf2JW6zFktwL4gdq4s4OuVTLIF/mHkC8zGyBYKOaVT/sA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, hosp_volume = _t, phy_volume = _t, overall_volume = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"hosp_volume", Int64.Type}, {"phy_volume", Int64.Type}, {"overall_volume", Int64.Type}}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Date"}, "Attribute", "Value"),
    #"Pivoted Column" = Table.Pivot(Table.TransformColumnTypes(#"Unpivoted Other Columns", {{"Date", type text}}, "en-US"), List.Distinct(Table.TransformColumnTypes(#"Unpivoted Other Columns", {{"Date", type text}}, "en-US")[Date]), "Date", "Value")
in
    #"Pivoted Column"

 

If the solutions @Syk  and i offered help you, please consider to mark them as a solution.

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

The data should be updated with no errors! However, you may want to reconsider this approach because dates as columns gets hairy really quickly. I'm not sure what your trying to achieve, just a note.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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