Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
JNYY
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." 

 

Fox Error.PNG

1 ACCEPTED SOLUTION
JNYY
Frequent Visitor

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!

View solution in original post

3 REPLIES 3
JNYY
Frequent Visitor

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!

v-caliao-msft
Employee
Employee

@JNYY,

 

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

TomMartens
Super User
Super User

Hey,

 

please provide the formula for your "LY Sales" measure.

 

Regards



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.