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

Calculate a running total to a specific date with inactive relationship

Hi,

 

I am trying to write a measure to calculate the cumulative number of activities that have been completed on a month by month basis, but am not getting the expected result - my best guess being because the relationship between my [Actual Finish Date] column and my date table is inactive.

 

My data table has several date fields (baseline start and finish, forecast start and finish, and actual start and finish), as well as an activity ID. The current active relationship is between the [Forecast Finish Date] and the date table (required for calculating the forecast activity count, and cumulative forecast count).

 

The current DAX code I am using is below:

Cumulative Activities Actually Completed =
VAR LastSalesDate = CALCULATE(LASTDATE(ScheduleDetail[Actual Finish]), ALL(ScheduleDetail) )
RETURN
IF(SELECTEDVALUE(DateTable[Date])>LastSalesDate,BLANK(),
CALCULATE(Count(ScheduleDetail[Activity ID]),
FILTER(ALLSELECTED(DateTable),
DateTable[Date] <= MAX(ScheduleDetail[Actual Finish])
)
)
)
 
If I were to use the USERELATIONSHIP function how would I implement this? Or, is there a better solution?
 
Many thanks
3 REPLIES 3
v-jayw-msft
Community Support
Community Support

Hi @envysn ,

 

It's better to share some sample data to us so that we can help you deal with the formula.

 

Best Regards,

Jay

 

Community Support Team _ Jay Wang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

Hi, 

 

Here is a small sample of the data I am using:

Activity IDProject IDBaseline StartBaseline FinishForecast StartForecast FinishActual StartActual Finish
ID1Area 117 May 202019 Aug 202120 May 202017 May 202022 May 202025 May 2020
ID2Area 122 Nov 20191 July 202019 Nov 201919 July 202019 Nov 201915 Jun 2020
ID3Area 231 July 202031 Aug 202026 July 202026 July 2020  
ID4Area 312 Sep 202118 Sep 202125 Sep 202125 Sep 2021  

 

Note that the active relationship is between the Forecast Finish column and the date column from my Date Table. 

amitchandak
Super User
Super User

@envysn , it should be something like this

Cumulative Activities Actually Completed =
VAR LastSalesDate = CALCULATE(LASTDATE(ScheduleDetail[Actual Finish]), ALL(ScheduleDetail) )
RETURN
IF(SELECTEDVALUE(DateTable[Date])>LastSalesDate,BLANK(),
CALCULATE(Count(ScheduleDetail[Activity ID]),
FILTER(ALLSELECTED(DateTable),
DateTable[Date] <= MAX(ScheduleDetail[Actual Finish])
) , userelation(DateTable[Date],ScheduleDetail[Actual Finish])
)
)

 

refer this example : https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...

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.