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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
itsmeanuj
Helper IV
Helper IV

Calculate total % in matrix visual

Hi Guys,

 

This is what my data looks like:

Monthpatient AgePatient ID
1-Jan<=30A1
1-Feb>30A2
1-Mar<=30A3
1-Jan<=30A4
1-Mar31-60A5
1-Jan<=30A6
1-Feb>30A7
1-Mar31-60A8
1-Jan<=30A9
1-Mar31-60A10
1-Jan<=30A11
1-Feb>30A12
1-Mar31-60A13
1-Mar>30A14
1-Feb31-60A15

 

I have created measures to show the total count of patients in each month in each category and their % contribution in each month.

 

Dummy Total = CALCULATE(DISTINCTCOUNT('Dummy Data'[Patient ID]))
Dummy Total% = DIVIDE(CALCULATE(count('Dummy Data'[Patient ID])),CALCULATE(COUNT('Dummy Data'[Patient ID]),ALLSELECTED()))
 
I have created a matric visual which looks like this
 itsmeanuj_1-1701253926644.png

 

Currently, the % is being calculated considering the denominator as 15 (count of patients across all the months), however, I need to show the denominator based on the total patients in that particular month. For Mar '23 (highlighted), the denominator should be 6 and not 15 while calculating %. Can someone please look into the Dummy total calculation and help me get the desired results? I am still learning DAX and need help.


 

6 REPLIES 6
HarishKM
Memorable Member
Memorable Member

@itsmeanuj Hey,
you can use this .

 

 

HarishKM_0-1701258164401.png


output based on months

HarishKM_1-1701258197692.png

 

 

Thanks

Harish M

 

johnyip
Solution Sage
Solution Sage

@itsmeanuj , please try the following

 

Dummy Total% = 
DIVIDE(CALCULATE(count('Dummy Data'[Patient ID])),CALCULATE(COUNT('Dummy Data'[Patient ID]),REMOVEFILTERS('Dummy Data'[patient Age])))

 



Please mark my post as the solution if this answers your question!
Appreciate your Kudos !!

@johnyip - Thank you so much. Seems like it is working but I will test it more. Also i want to show the values within parenthesis in my visual. Like (27%). Do you know how we can concatenate that?

There are two ways.

 

First is to create a new measure (or modify the existing one to the equivalent) as follows.

 

Dummy Total% (Reporting) = 
VAR Str = FORMAT([Dummy Total%]*100,"#.##")
RETURN
"(" & IF(FIND(".",Str)=LEN(Str),FORMAT([Dummy Total%]*100,"#"),Str) & "%)"

 

 

Second is to modify the display format of your existing measure to include brackets at the beginning and the end.

johnyip_0-1701315866548.png

 



Please mark my post as the solution if this answers your question!
Appreciate your Kudos !!

@johnyip - tried this but all the values go blank once I add this new column in values.

 

itsmeanuj_0-1701271717847.png

 

Is the sample data you provided having the same structure as your real data?



Please mark my post as the solution if this answers your question!
Appreciate your Kudos !!

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.