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
MadhuriReddy
New Member

Count of Occurrences of a measure

In PowerBI, I am trying to figure out how to perform a count of stores based upon the percentage groups

 

PCNT_Measure = DIVIDE(SUM('Table'[Visit]), SUM('Table'[Schedule]))
 

MadhuriReddy_1-1680257763352.png

For example, if all 4 months are selected

The desired result would be:
100% = 3 stores
75% = 1 store
50% = 2 stores

MadhuriReddy_2-1680257790352.png

This count/percentage would then change if different months were selected.

For example, if only months 1 through 3 were selected...
...then the count would be:

100% = 3 stores
66.7% = 3 stores

1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

Hi @MadhuriReddy 

 

You can use the following measure. This measure works when adding it to a visual which has [Store] column. If the visual doesn't have the [Store] column, the variable _pcnt cannot get the correct result then COUNTROWS would probably return a blank result.  

Count_PCNT = 
var _t = SUMMARIZE(ALLSELECTED('Table'),'Table'[Store],"PCNT",[PCNT_Measure])
var _pcnt = [PCNT_Measure]
return
COUNTROWS(FILTER(_t,[PCNT]=_pcnt))

vjingzhang_0-1680488588832.png

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

View solution in original post

3 REPLIES 3
v-jingzhang
Community Support
Community Support

Hi @MadhuriReddy 

 

You can use the following measure. This measure works when adding it to a visual which has [Store] column. If the visual doesn't have the [Store] column, the variable _pcnt cannot get the correct result then COUNTROWS would probably return a blank result.  

Count_PCNT = 
var _t = SUMMARIZE(ALLSELECTED('Table'),'Table'[Store],"PCNT",[PCNT_Measure])
var _pcnt = [PCNT_Measure]
return
COUNTROWS(FILTER(_t,[PCNT]=_pcnt))

vjingzhang_0-1680488588832.png

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

Thank you @v-jingzhang 

MadhuriReddy
New Member

Sample Data

StoreMonthScheduleVisit
Store #012022_0111
Store #012022_0211
Store #012022_0311
Store #012022_0411
Store #022022_0111
Store #022022_021 
Store #022022_0311
Store #022022_0411
Store #032022_0111
Store #032022_0211
Store #032022_031 
Store #032022_041 
Store #042022_0111
Store #042022_0211
Store #042022_0311
Store #042022_0411
Store #052022_0111
Store #052022_0211
Store #052022_0311
Store #052022_0411
Store #062022_011 
Store #062022_0211
Store #062022_0311
Store #062022_041 

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.