cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ahmedelgibaly
Frequent Visitor

how to count values of a measure

 

Hi Experts,

I need help on how to count data that is resulted from a measure. 

 

As per the below screenshot, I used the "Datadiff" function to get the numbers between 2 different dates "POR to Scopping" . Now i need to count how many "POR to scopping" that are more than 14 . The problem is that "POR to Scopping" is a measure and i can't get the "Count " function to work for measures and it only worke for columns!

 

Count a measure.JPG

 

 

 

 

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

Use COUNTX or COUNTROWS. Build a table using FILTER and perhaps ADDCOLUMNS that represents your table. Then use COUNTX against that table, perhaps with an additional filter for > 14. For example:

 

Measure Count = 
VAR __table = ALL('Table')
VAR __table1 = ADDCOLUMNS(__table,"__MyMeasure",[Measure])
RETURN
COUNTROWS(FILTER(__table1,[__MyMeasure] > 14))

@ me in replies or I'll lose your thread!!!
Check out my External Tool for Power BI Desktop! Microsoft Hates Greg's Quick Measures
YouTube Channel! Microsoft Hates Greg
Check out my latest book!

View solution in original post

2 REPLIES 2
Greg_Deckler
Super User
Super User

Use COUNTX or COUNTROWS. Build a table using FILTER and perhaps ADDCOLUMNS that represents your table. Then use COUNTX against that table, perhaps with an additional filter for > 14. For example:

 

Measure Count = 
VAR __table = ALL('Table')
VAR __table1 = ADDCOLUMNS(__table,"__MyMeasure",[Measure])
RETURN
COUNTROWS(FILTER(__table1,[__MyMeasure] > 14))

@ me in replies or I'll lose your thread!!!
Check out my External Tool for Power BI Desktop! Microsoft Hates Greg's Quick Measures
YouTube Channel! Microsoft Hates Greg
Check out my latest book!

View solution in original post

HI Dreg,

Thanks for the feedback!

 

I got it working by using the below statment :

Number of sites exceeding "POR To Scopping" Std Interval =
CALCULATE(COUNTA('Query1'[Site ID]), FILTER(Query1,Query1[POR to Scoping]>=14),FILTER(Query1,Query1[Site Scoping Sts]="P"))

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

November Power BI Update 768x460.png

Check it Out!

Click here to read more about the November 2021 Updates!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.