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
Digger
Post Patron
Post Patron

Count result of measure with condition

For example i have same tables

 

https://www.youtube.com/watch?v=8wjYWiZ7gpQ

 

how to count cumulative requests if cumulative requests sum >=10

 

I need only count and only in one measure

MeasureCount =


VAR sM = MAX(T1[Date])
VAR fM = MAX(Calendar[Date])
VAR sC = SELECTEDVALUE(T1[Project])

VAR CummulativeSumm =
Calculate(
Sum(T1[number])
,FILTER(ALLSELECTED(T1), fM >= T1[Date] && sM >= T1[Date] && T1[Project] = sC)
,Removefilters(T1[Date])
))

VAR CummulativeCount =
Calculate(
Count(T1[number])
,FILTER(ALLSELECTED(T1), fM >= T1[Date] && sM >= T1[Date] && T1[Project] = sC)
,Removefilters(T1[Date])
))

 

 

expected
VAR CummulativeCount =
Calculate(
Count(T1[number])
,FILTER(ALLSELECTED(T1), fM >= T1[Date] && sM >= T1[Date] && T1[Project] = sC)
,Removefilters(T1[Date])
,CummulativeSumm >= 10
))

1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @Digger ,

 

I see that you have two tables one for the date and another for projects, so I assume that you have a relationship between both tables.

 

If the relationship exists you don't need to have the two dates on your filter syntax.

 

What I can understand is that you want to return the values when the cumulative is above 10 so in this case you can make your cumulative like this:

MeasureCumulative = 

Var Cumulativevalue = CALCULATE([# Request],'Calendar'[Date]<= MAX('Calendar'[Date]))

Return
IF( Cumulativevalue >=10, Cumulativevalue)

 

MFelix_0-1653576490029.png

If you don't want to use the auxiliary table you can created the following measure:

 

MeasureCumulative = 

Var Cumulativevalue = CALCULATE(DISTINCTCOUNT(Request[Request ID]),'Calendar'[Date]<= MAX('Calendar'[Date]))

Return
IF( Cumulativevalue >=10, Cumulativevalue)

 

Check PBIX File attach.


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

1 REPLY 1
MFelix
Super User
Super User

Hi @Digger ,

 

I see that you have two tables one for the date and another for projects, so I assume that you have a relationship between both tables.

 

If the relationship exists you don't need to have the two dates on your filter syntax.

 

What I can understand is that you want to return the values when the cumulative is above 10 so in this case you can make your cumulative like this:

MeasureCumulative = 

Var Cumulativevalue = CALCULATE([# Request],'Calendar'[Date]<= MAX('Calendar'[Date]))

Return
IF( Cumulativevalue >=10, Cumulativevalue)

 

MFelix_0-1653576490029.png

If you don't want to use the auxiliary table you can created the following measure:

 

MeasureCumulative = 

Var Cumulativevalue = CALCULATE(DISTINCTCOUNT(Request[Request ID]),'Calendar'[Date]<= MAX('Calendar'[Date]))

Return
IF( Cumulativevalue >=10, Cumulativevalue)

 

Check PBIX File attach.


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



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.