Forum Discussion
Calculating change in data between two report dates within the same sheet
- Anonymous5 years ago
Hi jh292
I build a table like yours to have a test.
To calculate insight gathered in the last 2 days, firstly calculate the Maxdate1(2020/10/13) within last 2 days and then calculate the Maxdate2 which is before Maxdate1(2020/10/11).
Measure:
Measure = VAR _Max2Days = MAXX ( FILTER ( ALL ( 'Table' ), DATEDIFF ( 'Table'[Report Date], TODAY (), DAY ) <= 2 ), 'Table'[Report Date] ) VAR _MaxMinus = MAXX ( FILTER ( ALL ( 'Table' ), 'Table'[Report Date] < _Max2Days ), 'Table'[Report Date] ) VAR _SumA = SUMX ( FILTER ( 'Table', 'Table'[Report Date] = _Max2Days ), 'Table'[Known Insight] ) VAR _SumB = SUMX ( FILTER ( 'Table', 'Table'[Report Date] = _MaxMinus ), 'Table'[Known Insight] ) RETURN _SumA - _SumBResult is A: 6-5=1,B:6-6=0,C:5-4=1 sum=2.
You can download the pbix file from this link: Calculating change in data between two report dates within the same sheet
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Affraid that still just totals everything regardless of date....
Thanks for trying!
Hi jh292
I build a table like yours to have a test.
To calculate insight gathered in the last 2 days, firstly calculate the Maxdate1(2020/10/13) within last 2 days and then calculate the Maxdate2 which is before Maxdate1(2020/10/11).
Measure:
Measure =
VAR _Max2Days =
MAXX (
FILTER (
ALL ( 'Table' ),
DATEDIFF ( 'Table'[Report Date], TODAY (), DAY ) <= 2
),
'Table'[Report Date]
)
VAR _MaxMinus =
MAXX (
FILTER ( ALL ( 'Table' ), 'Table'[Report Date] < _Max2Days ),
'Table'[Report Date]
)
VAR _SumA =
SUMX (
FILTER ( 'Table', 'Table'[Report Date] = _Max2Days ),
'Table'[Known Insight]
)
VAR _SumB =
SUMX (
FILTER ( 'Table', 'Table'[Report Date] = _MaxMinus ),
'Table'[Known Insight]
)
RETURN
_SumA - _SumB
Result is A: 6-5=1,B:6-6=0,C:5-4=1 sum=2.
You can download the pbix file from this link: Calculating change in data between two report dates within the same sheet
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.