cancel
Showing results for
Did you mean:
Frequent Visitor

## Create a Measure that can be sliced by a range of Dates

Hi all,

Appreciate if anyone can help me with this.

Background: To create a measure "LY Sales" that can be sliced by a range of TransactionDate

Problem Faced: It works when I sliced the data by individual day. However, when I chose the period 14/6/2017 to 15/6/2017, I got an error message "A table of multiple values was supplied where a single value was expected."

1 ACCEPTED SOLUTION

Accepted Solutions
Frequent Visitor

## Re: Create a Measure that can be sliced by a range of Dates

Hi all,

I solved the problem with the following measure:

FOX LY Sales =
CALCULATE (SUM('FOX LY Data'[Net Sales]),
FILTER(
ALL(DateKey),
COUNTROWS(FILTER(DateKey, EARLIER(DateKey[Date]) = DATEADD(DateKey[Date], -1, YEAR)))))

Thanks all whom have replied!

3 REPLIES 3
Super User

## Re: Create a Measure that can be sliced by a range of Dates

Hey,

Regards

Hamburg - Germany
If I answer you question, please mark my post as solution, this will also help others.
Proud to be a Datanaut!
Moderator

## Re: Create a Measure that can be sliced by a range of Dates

Based on your DAX expression, it seems that you need to calculated the value for same period for last year. If that is the case, you could use SAMEPERIODLASTYEAR function which returns a table that contains a column of dates shifted one year back in time from the dates in the specified dates column, in the current context.

https://msdn.microsoft.com/en-us/library/ee634972.aspx

Regards,

Charlie Liao

Frequent Visitor

## Re: Create a Measure that can be sliced by a range of Dates

Hi all,

I solved the problem with the following measure:

FOX LY Sales =
CALCULATE (SUM('FOX LY Data'[Net Sales]),
FILTER(
ALL(DateKey),
COUNTROWS(FILTER(DateKey, EARLIER(DateKey[Date]) = DATEADD(DateKey[Date], -1, YEAR)))))

Thanks all whom have replied!

Announcements

#### Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

#### Power BI Helps Homeless and Trouble Youth

We spoke with Power BI Super User, Greg Deckler, about his charity work

#### Watch Sessions On Demand!

Continue your learning in our online communities.

Top Kudoed Authors
Users Online
Currently online: 153 members 1,916 guests
Recent signins: