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
macas01
Frequent Visitor

Dynamic count of equal values per column and cond formatting when lower then % of column total

Hello All,

I have a raw data table roughly similiar to the folliwing one:

ItemCategoryAttribute Value
VE1WHITEF_011234AA
VE1WHITEF_06AA112
VE1WHITEF_05BB112
VE2WHITEF_011234AA
VE2WHITEF_06AA112
VE2WHITEF_05BB112
VE7WHITEF_05BB112
VE7WHITEF_06AA112
VE7WHITEF_011234AD
VE8REDF_041234AA
VE8REDF_011234AA
VE8REDF_02REP_2
VE6REDF_02REP_2
VE6REDF_041234AA
VE6REDF_011234AA
VE3BLUEF_011234AC
VE3BLUEF_05BB112
VE3BLUEF_03XYZ1
VE4BLUEF_011234AB
VE4BLUEF_05GG14
VE4BLUEF_03XYZ2
VE5BLUEF_011234AC
VE5BLUEF_05BB112
VE8REDF_05GG14
VE8REDF_06AA101

So basically an unpivoted source data table.

And i am showing this data on a Matrix Visual where

Rows: [Category], [Item]

Columns: [Attribute]

Values: [Value]

 

With this results:

ItemCategoryF_01F_02F_03F_04F_05F_06
VE1WHITE1234AA   BB112AA112
VE2WHITE1234AA   BB112AA112
VE3BLUE1234AC XYZ1 BB112 
VE4BLUE1234AB XYZ2 GG14 
VE5BLUE1234AC   BB112 
VE6RED1234AAREP_2 1234AA  
VE7WHITE1234AD   BB112AA112
VE8RED1234AAREP_2 1234AAGG14AA101

 

 

What i need to do now is to highlight all the values, for each separate column, that show up below a fixed percentage of total count of that column.

Let's say this percentage is 25%, in this case i would have:

ItemCategoryF_01F_02F_03F_04F_05F_06
VE1WHITE1234AA   BB112AA112
VE2WHITE1234AA   BB112AA112
VE3BLUE1234AC XYZ1 BB112 
VE4BLUE1234AB XYZ2 GG14 
VE5BLUE1234AC   BB112 
VE6RED1234AAREP_2 1234AA  
VE7WHITE1234AD   BB112AA112
VE8RED1234AAREP_2 1234AAGG14AA101

So just to be clear: referring to column F_06, there are 4 items in total in it and the value "AA101" is showing up 1/4 --> 25% so Highilight! Same thing for F_01: 1234AC is 2/8 -->25%, 1234AD and 1234AC are 1/8 -->12,5%.

 

 

And also it needs to change dinamically accordingly to Slicers i have in my dashboard ([Item], [Category]).

For example if are filtered only Item "VE3","VE4","VE5" and "VE7":

ItemCategoryF_01F_02F_03F_04F_05F_06
VE3BLUE1234AC XYZ1 BB112 
VE4BLUE1234AB XYZ2 GG14 
VE5BLUE1234AC   BB112 
VE7WHITE1234AD   BB112AA112

 

 

The path i am following right now is to create a measure, and then refer the conditional formatting of [Value] to that measure.

The measure should calculate the count of equal values per similar [Attribute] but i am struggling a little bit because my source table is unpivoted and i am not so good in table processing with DAX and i am losting in it ^^'

I have tried also creating a custom table using the summarize and the count function, link it to the main table, and refer the cond format to the count column of the summarized table. It workish, but it does not evolve accordingly to slicers, it's a fixed calculation and it's not what i need

 

Hope that everything is clear

Looking forward to have some suggestion

 

Thank you!!

1 ACCEPTED SOLUTION

Ok, I figure it out by myself.

Probably is not the most efficient way, but it's working 😃. I post it here for whoever needs it.

This is the measure:

Measure = 
var tab = CALCULATETABLE(SUMMARIZE('Table','Table'[Value],"cnt",count('Table'[Value])),ALLSELECTED('Table'[Category],'Table'[Item],'Table'[Value]))
return
SUMX(tab,IF(SELECTEDVALUE('Table'[Value])='Table'[Value],[cnt],0))/CALCULATE(COUNTAX(SUMMARIZE('Table','Table'[Item]),'Table'[Item]),ALLSELECTED('Table'[Item],'Table'[Category]))

And then apply conditional formatting on "Value" as following:

Screenshot 2022-11-21 at 16.03.42.png

 

This is the result ( i kept "Measure" in table only for sake of clarity):

Screenshot 2022-11-21 at 16.04.06.png

And it change accordingly to filters:

Screenshot 2022-11-21 at 16.04.30.png

View solution in original post

4 REPLIES 4
macas01
Frequent Visitor

Until now, i have found a way to calculate the total count for each column that change accordingly to filtered rows.

Measure = CALCULATE(COUNTAX(SUMMARIZE('Table','Table'[Item]),'Table'[Item]),ALLSELECTED('Table'[Item],'Table'[Category]))

Screenshot 2022-11-17 at 13.56.15.png

So this will be my denominator on my overall measure which i will then apply the Conditional Formatting.

I am still figuring out the count of the equal values for each column

Ok, I figure it out by myself.

Probably is not the most efficient way, but it's working 😃. I post it here for whoever needs it.

This is the measure:

Measure = 
var tab = CALCULATETABLE(SUMMARIZE('Table','Table'[Value],"cnt",count('Table'[Value])),ALLSELECTED('Table'[Category],'Table'[Item],'Table'[Value]))
return
SUMX(tab,IF(SELECTEDVALUE('Table'[Value])='Table'[Value],[cnt],0))/CALCULATE(COUNTAX(SUMMARIZE('Table','Table'[Item]),'Table'[Item]),ALLSELECTED('Table'[Item],'Table'[Category]))

And then apply conditional formatting on "Value" as following:

Screenshot 2022-11-21 at 16.03.42.png

 

This is the result ( i kept "Measure" in table only for sake of clarity):

Screenshot 2022-11-21 at 16.04.06.png

And it change accordingly to filters:

Screenshot 2022-11-21 at 16.04.30.png

macas01
Frequent Visitor

@lkalawski here is a link to download the SampleBi.pbix 

Thanks

lkalawski
Memorable Member
Memorable Member

Hi @macas01 ,

In this example, the solution you mentioned is enough - measure and conditional formatting. If you have started to write a measure, please paste it here or add a sample file that I can use to write the measure.

 

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.

Top Solution Authors