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.
Hi All,
I have this data set that is updated daily:
In order to calculate a daily diff of [total] for each id I've added the following columns:
total_yesterday = LOOKUPVALUE(
[total],
[file_date],[file_date]-1,
[Id],[Id],
[total])
daily_diff = [total] - [total_yesterday]
to create this:
My problem is, with ~10000 unique ids and ~30 days of data, the [total_yesterday] column takes about 10-12 minuts to be calculated.
Is this the correct way to find the daily total? or is there a better, more efficiant way to make this calculation?
Thanks for the help!
Solved! Go to Solution.
Hi @Yaa_D ,
Try this
total_yesterday = var _yeasterday=CALCULATE([total],PREVIOUSDAY('Table'[file_date]))
return IF(ISBLANK(_yeasterday),[total],+_yeasterday)
daily_diff = [total]-[total_yesterday]
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@Yaa_D my take on this is to use a measure like this. In case, you have gaps in date
Measure =
VAR _currentTotal =
SUM ( 'Table'[total value] )
VAR _visibleDate =
MAX ( 'Table'[file_date] )
VAR _visibleId =
MAX ( 'Table'[id] )
VAR _immediatelyPreceding =
CALCULATE ( MAX ( 'Table'[file_date] ), 'Table'[file_date] < _visibleDate )
VAR _immediatelyPrecedingTotal =
CALCULATE (
SUM ( 'Table'[total value] ),
'Table'[id] = _visibleId
&& 'Table'[file_date] = _immediatelyPreceding,
REMOVEFILTERS ( 'Table' )
)
RETURN
_currentTotal - _immediatelyPrecedingTotal
@Yaa_D my take on this is to use a measure like this. In case, you have gaps in date
Measure =
VAR _currentTotal =
SUM ( 'Table'[total value] )
VAR _visibleDate =
MAX ( 'Table'[file_date] )
VAR _visibleId =
MAX ( 'Table'[id] )
VAR _immediatelyPreceding =
CALCULATE ( MAX ( 'Table'[file_date] ), 'Table'[file_date] < _visibleDate )
VAR _immediatelyPrecedingTotal =
CALCULATE (
SUM ( 'Table'[total value] ),
'Table'[id] = _visibleId
&& 'Table'[file_date] = _immediatelyPreceding,
REMOVEFILTERS ( 'Table' )
)
RETURN
_currentTotal - _immediatelyPrecedingTotal
Hi @Yaa_D ,
Try this
total_yesterday = var _yeasterday=CALCULATE([total],PREVIOUSDAY('Table'[file_date]))
return IF(ISBLANK(_yeasterday),[total],+_yeasterday)
daily_diff = [total]-[total_yesterday]
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@Yaa_D , Try like, if this can help
total_yesterday = Maxx(filter(Table, [file_date] = earlier([file_date]) && [Id] =earlier([Id])), [total])
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
43 | |
23 | |
21 | |
15 | |
15 |
User | Count |
---|---|
45 | |
31 | |
30 | |
18 | |
17 |