cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Midguel
Helper I
Helper I

Get difference in Matrix between two dates of a slicer (show zeros)

Hi everyone, I'm having problems creating a measure that can calculate the difference between 2 dates in a slicer, i created this one but doesn't seems to work like i would want:

DELTA2 = 
VAR LASTDAY = [HOY]
VAR PREVDAY = [ayer]
VAR TOODAY = CALCULATE(SUM('DATA BASE'[Tons]),'DATA BASE'[FECHA DE CAPTURA] = LASTDAY,VALUES('DATA BASE'[OP]))
VAR YESTERDAY = CALCULATE(SUM('DATA BASE'[Tons]),'DATA BASE'[FECHA DE CAPTURA] = PREVDAY,VALUES('DATA BASE'[OP]))
RETURN
TOODAY-YESTERDAY

where:

[HOY] = CALCULATE(MAX('DATA BASE'[FECHA DE CAPTURA]),ALL('DATA BASE'))

and,

[ayer] = CALCULATE(MAX('DATA BASE'[FECHA DE CAPTURA]) - 1,ALL('DATA BASE'))
 

my result is this:

pppp.PNGdel.PNG
it only kinda works with the last 2 dates, also i filtered the results of DELTA2 = 0, so it only displays the changes between days.
I would like to reach a matrix like this (whatever date i choose, will be always one day and the next):

aaaaaa.PNG
if anyone can help me, i would really apreciatted.

1 REPLY 1
Midguel
Helper I
Helper I

How can i point to a slicer where i can select the days? instead of have to use 2 measures (today & yesterday) inside this measure

Helpful resources

Announcements
Carousel_PBI_Wave1

2023 Release Wave 1 Plans

Power BI release plans for 2023 release wave 1 describes all new features releasing from April 2023 through September 2023.

Power BI Summit Carousel 2

Global Power BI Training

Make sure you register today for the Power BI Summit 2023. Don't miss all of the great sessions and speakers!

Thank you 2022 Review

2022 Monthly Feature Releases

We had a great 2022 with a ton of feature releases to help you drive a data culture.

Top Solution Authors
Top Kudoed Authors