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
sarveshkalyan
Advocate I
Advocate I

To Find the earliest date of a measure when running total crosses a threshold

Hi,

I am faced with a challenge of getting the earliest date of a measure in powerbi, since it is a measure i am not able to proceed without column references.

This is a sample dataset,

AppsTotalCountRunning CountPercent CoveredTarget Reached(>85%)DateEarliest Date
11160474778%No10/12/202115/12/2021
1116035083%No13/12/202115/12/2021
1116095998%Yes15/12/202115/12/2021
11160160100%Yes17/12/202115/12/2021
12434272779%No19/12/202121/12/2021
1243433088%Yes21/12/202121/12/2021
1243423294%Yes23/12/202121/12/2021

sarveshkalyan_0-1660752419350.png

Here, except for App Code, Count, Date, all the other fields are measures. Earliest Date is the field that i wish to calculate

Earliest date is the first date when a running total count specific to an app crosses the 85% threshold.

 
With the following measure i am able to get multiple dates, but i am not able to apply FIRSTDAY, RANKX OR TOPN to get the 1st output without a column reference
Date after 85% =
IF('App Progress'[Percent Covered]>=0.85,
    MINX('App Progress','App Progress'[Date]) ,
BLANK())
 
The following measure gives me just the 1st day in each app, i want to modify this to include the threshold >85% to get the expected value
Earliest Date =
    VAR _App = MIN('App Progress'[Apps])
    RETURN
MINX( FILTER(ALL('App Progress'), 'App Progress'[Apps] = _App),'App Progress'[Date])
 
Please let me know on how to proceed
 
 

 

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

Does it have to be measures?  These facts seem to be immutable (not impacted by user filter choices) so calculated columns should be sufficient.

Percent Covered = 
var a = [Apps]
var d = [Date]
return divide(calculate(sum('App Progress'[Count]),ALL('App Progress'),'App Progress'[Apps]=a,'App Progress'[Date]<=d),[Total])

Earliest Date = 
var a = [Apps]
return calculate(minx('App Progress','App Progress'[Date]),ALL('App Progress'),'App Progress'[Apps]=a,'App Progress'[Percent Covered]>=0.85)

 

see attached.

View solution in original post

2 REPLIES 2
sarveshkalyan
Advocate I
Advocate I

Thanks, you are right. Calculated columns helped me to solve this 

lbendlin
Super User
Super User

Does it have to be measures?  These facts seem to be immutable (not impacted by user filter choices) so calculated columns should be sufficient.

Percent Covered = 
var a = [Apps]
var d = [Date]
return divide(calculate(sum('App Progress'[Count]),ALL('App Progress'),'App Progress'[Apps]=a,'App Progress'[Date]<=d),[Total])

Earliest Date = 
var a = [Apps]
return calculate(minx('App Progress','App Progress'[Date]),ALL('App Progress'),'App Progress'[Apps]=a,'App Progress'[Percent Covered]>=0.85)

 

see attached.

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.