Reputation: 43
My question might be simple but I've been stuck here for a while.
I'm trying to get the values for current month and previous month. I created 2 Measures to do that (CurrentVal and PreviousVal).
My DAX measures are:
CurrentVal = SUM ( Database[KPI_Value] )
PreviousVal =
CALCULATE (
[CurrentVal];
PREVIOUSMONTH ( DIM_Date[Date] )
)
In the image below, when displayed as a table, you can see it's working fine.
However, I don't want a table like that, but instead I want a slicer where the user can select the month and he will be able to see the current and previous month values, just like the image below.
The problem, as you can see, is that when I remove the Date from the table and include the slicer, the PreviousVal returns always blank (in this example, it should return 0,44). What am I doing wrong here?
Thanks in advance!
Upvotes: 0
Views: 2558
Reputation: 7891
What you have set up will work, assuming:
Date
fields in the Database
and DIM_Date
tablesDIM_Date
is marked as a date table (Table view, Modelling tab, Mark as Date Table
)Here's a worked example: https://excel.solutions/so20181121_previousmonth/
Upvotes: 3