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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
epelton
Frequent Visitor

Measures with shared headers

I am attempting to do the exact same thing as this post, but getting strange results.

 

Solved: Shared header for measures in a matrix - Microsoft Power BI Community

 

I would like to display my measures with a shared header like this...

 

epelton_0-1678456831196.png

 

 

In the first attempt below, I apply the two columns from "Table" to the columns of a matrix as in the above post. This does not however display the two columns. Only the first one. In the second attempt below, I can accomplish displaying two column headers by moving one of the columns to the values field along with "measure" from "Table". This nearly works, but is displaying the word from column 2 instead of the value from the measure, and the headers are not the values from column two in "table" as I would like.

EDIT: Zirect Labor was Direct Labor. I Noticed that the DAX switch was simplay falling through alphabetically due to the MAX function, so I tried to Zirect to check, and that was happening. I'm not entirely comfortable with this DAX, so I'm not sure if thats what it should do or not, but of course, I want to show each case in the switch statment, so there should be 9 total columns.

 

Here is my measure...

 

Measure =
SWITCH (
    TRUE (),
    MAX ( [Column1] ) = "Current"&& MAX ( [Column2] ) = "Gross Revenue", [Gross Rev],
    MAX ( [Column1] ) = "Current"&& MAX ( [Column2] ) = "Net Revenue", [Net Rev],
    MAX ( [Column1] ) = "Current"&& MAX ( [Column2] ) = "Zirect Labor", [Direct Labor],
    MAX ( [Column1] ) = "YTD"&& MAX ( [Column2] ) = "Gross Revenue", [YTD GR],
    MAX ( [Column1] ) = "YTD"&& MAX ( [Column2] ) = "Net Revenue", [YTD NR],
    MAX ( [Column1] ) = "YTD"&& MAX ( [Column2] ) = "Zirect Labor", [YTD DL],
    MAX ( [Column1] ) = "JTD"&& MAX ( [Column2] ) = "Gross Revenue", [JTD GR],
    MAX ( [Column1] ) = "JTD"&& MAX ( [Column2] ) = "Net Revenue", [JTD NR],
    MAX ( [Column1] ) = "JTD"&& MAX ( [Column2] ) = "Zirect Labor", [JTD DL])
 
My first attempt which matches the post above...

epelton_0-1678397577449.png

 

My second attempt which at least displays a shared header, but incorrect secondary headers, which I want to be the values in column2

epelton_1-1678397708235.png

This is the data in "Table"

epelton_2-1678397764972.png


@v-yalanwu-msft 

 

5 REPLIES 5
v-cgao-msft
Community Support
Community Support

Hi @epelton ,

Please try expand all down one level in the hierarchy.

vcgaomsft_2-1679365498373.png

vcgaomsft_1-1679365449478.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

Thanks Gao. This does display the headers correctly, however, the client does not consider this to be a solution, as they drill up and down while using the report and want both headers displayed regardless.

bolfri_1-1679526475446.png

 

 

Measure = 
SWITCH(TRUE(),
    SELECTEDVALUE(GUI_Headers[Header_lvl1])="Total" && SELECTEDVALUE(GUI_Headers[Header_lvl2]) = "Sum header", [Sum],
    SELECTEDVALUE(GUI_Headers[Header_lvl1])="Total" && SELECTEDVALUE(GUI_Headers[Header_lvl2]) = "Avg header", [Avg],
    SELECTEDVALUE(GUI_Headers[Header_lvl1])="Last day" && SELECTEDVALUE(GUI_Headers[Header_lvl2]) = "Sum LD header", [Sum LD],
    SELECTEDVALUE(GUI_Headers[Header_lvl1])="Last day" && SELECTEDVALUE(GUI_Headers[Header_lvl2]) = "Avg LD header", [Avg LD]
)

 

Works for me. You can still drill down Region > City. 🙂

 





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

Proud to be a Super User!




bolfri
Super User
Super User

Can you post here a sample data to work with? eg via wetransfer.com

Also an information (paint/excel) how do you want this to look like would be cool.





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

Proud to be a Super User!




I've updated the post with how I want the headers to be displayed. The data is just floats in measures.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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