Forum Discussion
Calculating Difference between Two Days based on a variable
- 4 years ago
Hi Anonymous ,
You can use VAR to improve preformance.
Previous SMR = VAR _t = TOPN ( 1, FILTER ( DailyProduction, DailyProduction[EIID] = EARLIER ( DailyProduction[EIID] ) && DailyProduction[SMR] < EARLIER ( DailyProduction[SMR] ) ), [Date], DESC ) RETURN MAXX ( _t, [SMR] )Best Regards
Community Support Team _ chenwu zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Anonymous ,
Don't quite understand your explanation. Can you give simple data and include the expected output values? It is best to share it in a tabular format.
Or you can try this expression:
Column =
VAR _last =
TOPN (
1,
FILTER (
'Table',
[EIID] = EARLIER ( 'Table'[EIID] )
&& [date&shift] < EARLIER ( 'Table'[date&shift] )
),
[date&shift], DESC
)
RETURN
IF ( COUNTROWS ( _last ) > 0, [Shift] - MAXX ( _last, [Shift] ) )
Result:
Pbix in the end you can refer.
Best Regards
Community Support Team _ chenwu zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- v-chenwuz-msft4 years agoCommunity Support
Hi Anonymous ,
You can use VAR to improve preformance.
Previous SMR = VAR _t = TOPN ( 1, FILTER ( DailyProduction, DailyProduction[EIID] = EARLIER ( DailyProduction[EIID] ) && DailyProduction[SMR] < EARLIER ( DailyProduction[SMR] ) ), [Date], DESC ) RETURN MAXX ( _t, [SMR] )Best Regards
Community Support Team _ chenwu zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Anonymous4 years agoNot applicable
Thanks a lot! It still takes a while to run but I think that is just the nature of the calculation I am doing. I am changing the actual input of the database to include this number already so that I don't have to calculate it via formula.
Thanks again