Power BI Time based Measure not working when slicer (Year) applied

SAMEPERIODLASTYEAR DAX not working with a year filter

I wanted to create a KPI showing year to Date and Last year to date.

So I have Measures:

YTD Complaints = TOTALYTD(‘fact Fact'[Complaints],’dim Date'[date].[Date])

LY YTD Complaints = CALCULATE([YTD Complaints],SAMEPERIODLASTYEAR(‘dim Date'[date].[Date])) 

I have a slicer on year so i can select the year to look at. Without the year selected its fine (Ive put the data into a table simply to have a look at)

As you can see the last year information is shown in the column 

if I choose 2019 to look at i want to see 2019 with Last year against it

See how the Last year value disappears. I was expecting that creating this measure would allow you to see Last years metric even with a year slicer set

The answer to this is actually quite simple

Here I have used Year which is an actual data column in my date table to slice the data with and its not working

This time I have used year from my date hierarchy and its worked

Which to me meas that if you are using these kind of time based measures, if you want to slice by date you HAVE to use the time period from the date hierarchy in the slicer rather than another data item (As in the example. I used the Year column created in the date dimension)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create your website with WordPress.com
Get started
%d bloggers like this: