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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
adventurer7
Helper I
Helper I

Measures to Columns

Hello. I currently have a table in this format :

NameCategory ACategory BCategory C
Name 1001
Name 2101
Name 3111
Name 4100
Name 5010

 

And I have these measures to count the zeroes :

Category A Count = COUNTROWS(FILTER(Table1,Table1[Category A]=0))

Category B Count = COUNTROWS(FILTER(Table1,Table1[Category B]=0))

Category C Count = COUNTROWS(FILTER(Table1,Table1[Category C]=0))

 

And the percentage of zeroes over count of rows :

Category A % = Category A Count/COUNT(Table1[Name])

Category B % = Category B Count/COUNT(Table1[Name])

Category C % = Category C Count/COUNT(Table1[Name])

 

Is there a way to achieve below matrix format without unpivoting the table? I think there should only be one measure for count and one for % but I can't make it work. Thanks in advance!

 

 Count%
Category A240%
Category B360%
Category C240%
1 ACCEPTED SOLUTION
v-yueyunzh-msft
Community Support
Community Support

Hi, @adventurer7 

Here are the steps you can refer to :
(1)My test data is the same as yours.

(2)We can use dax to unpivot your table, you can click "New Table":

Table 2 = UNION( ADDCOLUMNS( SELECTCOLUMNS('Table',"Value",[Category A],"Name",[Name]) , "Category","Category A"),
ADDCOLUMNS( SELECTCOLUMNS('Table',"Value",[Category B],"Name",[Name]) , "Category","Category B"),
ADDCOLUMNS( SELECTCOLUMNS('Table',"Value",[Category C],"Name",[Name]) , "Category","Category C"))

vyueyunzhmsft_0-1671589900846.png

 

(3)Then we can create two measures:

Count = CALCULATE( COUNT('Table 2'[Value]) , 'Table 2'[Value]=0)
% = DIVIDE([Count], DISTINCTCOUNT('Table 2'[Name]))

(4)Then we can put the measure on the visual and we can meet your need:

vyueyunzhmsft_1-1671589948614.png

 

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

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

6 REPLIES 6
v-yueyunzh-msft
Community Support
Community Support

Hi, @adventurer7 

Here are the steps you can refer to :
(1)My test data is the same as yours.

(2)We can use dax to unpivot your table, you can click "New Table":

Table 2 = UNION( ADDCOLUMNS( SELECTCOLUMNS('Table',"Value",[Category A],"Name",[Name]) , "Category","Category A"),
ADDCOLUMNS( SELECTCOLUMNS('Table',"Value",[Category B],"Name",[Name]) , "Category","Category B"),
ADDCOLUMNS( SELECTCOLUMNS('Table',"Value",[Category C],"Name",[Name]) , "Category","Category C"))

vyueyunzhmsft_0-1671589900846.png

 

(3)Then we can create two measures:

Count = CALCULATE( COUNT('Table 2'[Value]) , 'Table 2'[Value]=0)
% = DIVIDE([Count], DISTINCTCOUNT('Table 2'[Name]))

(4)Then we can put the measure on the visual and we can meet your need:

vyueyunzhmsft_1-1671589948614.png

 

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

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

Works like a charm! Thanks Aniyaaaa appeciate it

bolfri
Solution Sage
Solution Sage

Can you tell us why you don't want to unpivot the data?





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

Proud to be a Super User!




Hi! There are already existing visuals and several columns/measures made using this table format.

Are you suggesting I reference/duplicate the table and unpivot it?

Actually sometimes it's better to rebuild whole dashboard using correct model than trying to find a "workaround" solutions that you will hate in the future. Power BI is super-easy, fast and even if you need to rebuild some stuff it will be much easier, because right know you know what you want.

 

If you want, you can send me a pbix file. I can rebuild it for you. 🙂





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

Proud to be a Super User!




amitchandak
Super User
Super User

@adventurer7 , In the Matrix switch values to row, should do the job

 

of try calculation group

 

Calculation Groups- Measure Slicer, Measure Header Grouping, Measure to dimension conversion. Complex Table display : https://youtu.be/qMNv67P8Go0

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Feb2025 NL Carousel

Fabric Community Update - February 2025

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