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
AishwaryaP_
Regular Visitor

Count with multiple conditions

Q1_AQ1_BQ1_CQ1_DState
45221
24112
32252
35331
35241
21521
31451
12152
23531

 

I want to calculate count of 4 from Q1_A, Q1_B, Q1_C, Q1_D for State= 1 and want to calculate % of Count of 4/count State =1 

The answer should be,

Count of 4 for State 1= 3, 

Total count of state 1 = 6 , % = 50% 

 

Need help in writing a measure. 

1 ACCEPTED SOLUTION
ryan_mayu
Super User
Super User

@AishwaryaP_ 

add an index colomn and select index and state column to unpivot other columns.

Then create a measure

measure = CALCULATE(COUNTROWS('Table'),FILTER('Table','Table'[State]=1 && 'Table'[Value]=4))
/CALCULATE(DISTINCTCOUNT('Table'[Index]),FILTER('Table','Table'[State]=1))

1.PNG

pls see the attachment below





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

Proud to be a Super User!




View solution in original post

2 REPLIES 2
Vera_33
Resident Rockstar
Resident Rockstar

Hi @AishwaryaP_ 

 

If you don't want to change the table format, then try this one

Vera_33_0-1642729126257.png

count = 
VAR T1=FILTER('Table','Table'[State]=1)
RETURN
COUNTROWS(FILTER(T1, 4 IN {[Q1_A],[Q1_B],[Q1_C],[Q1_D]}))

count% = 
VAR T1=FILTER('Table','Table'[State]=1)
RETURN
[count]/COUNTROWS(T1)
ryan_mayu
Super User
Super User

@AishwaryaP_ 

add an index colomn and select index and state column to unpivot other columns.

Then create a measure

measure = CALCULATE(COUNTROWS('Table'),FILTER('Table','Table'[State]=1 && 'Table'[Value]=4))
/CALCULATE(DISTINCTCOUNT('Table'[Index]),FILTER('Table','Table'[State]=1))

1.PNG

pls see the attachment below





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

Proud to be a Super User!




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.