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
Anonymous
Not applicable

Calculation error in measure for last year Sales?

Hey, 

I am trying to Filter last year sales, but I am getting an error. Please see below for my formula. 

 

Total Sales = SUM(Sales_Details[TotalPrice])

 

2018 Forecast =
CALCULATE([Total Sales],
FILTER(Dates, Dates[Sales Data].[Year] = "2018"))

 

Error - 

 

Error.PNG

 

 

Please click here for the sample file. 

Can anybody please tell me what I am doing wrong?

 

Thank you so much

 

3 ACCEPTED SOLUTIONS
ChrisMendoza
Resident Rockstar
Resident Rockstar

@Anonymous -

It looks like you've enclosed "2018" as a text string. Take out the quotes or change the Data Type to Text






Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

Proud to be a Super User!



View solution in original post

d_gosbell
Super User
Super User

You have quotes around the value 2018 which tells DAX to treat that value as text instead of a number. Removing the quotes around 2018 should fix this issue.

 

eg

 

2018 Forecast =
CALCULATE([Total Sales],
FILTER(Dates, Dates[Sales Data].[Year] = 2018 ))

View solution in original post

v-eachen-msft
Community Support
Community Support

Hi @Anonymous ,

 

Dates[Sales Data].[Year] returns a value(whole number), but "2018" is text so they are different types.

So you need to use Dates[Sales Data].[Year] = 2018 or FORMAT(Dates[Sales Data].[Year],"0000") = "2018".

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Thank you all for your help. I really appreciate it. 

v-eachen-msft
Community Support
Community Support

Hi @Anonymous ,

 

Dates[Sales Data].[Year] returns a value(whole number), but "2018" is text so they are different types.

So you need to use Dates[Sales Data].[Year] = 2018 or FORMAT(Dates[Sales Data].[Year],"0000") = "2018".

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.
d_gosbell
Super User
Super User

You have quotes around the value 2018 which tells DAX to treat that value as text instead of a number. Removing the quotes around 2018 should fix this issue.

 

eg

 

2018 Forecast =
CALCULATE([Total Sales],
FILTER(Dates, Dates[Sales Data].[Year] = 2018 ))

ChrisMendoza
Resident Rockstar
Resident Rockstar

@Anonymous -

It looks like you've enclosed "2018" as a text string. Take out the quotes or change the Data Type to Text






Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

Proud to be a Super User!



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.