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

MdxScript(Model) (8, 67) Calculation error in measure A column specified in the call to function

Hi Team,

Am creating new measures based on year column.

Measure 1:

CY Revenue =
var CY = MAX('Sales Data'[Year])
return
CALCULATE(SUM('Sales Data'[Total Revenue]),'Sales Data'[Year]=CY)
 
Measure 2:
PY Revenue = CALCULATE([CY Revenue],SAMEPERIODLASTYEAR('Sales Data'[Year]))
 
when am try fetch data from 2nd measure am getting bellow error, please help on same.
capture20210525145323935.png
1 ACCEPTED SOLUTION

Hi @Anonymous ,

 

SAMEPERIODLASTYEAR takes date column as input, but you are just giving it year part of your date.

Check details here:

https://docs.microsoft.com/en-us/dax/sameperiodlastyear-function-dax

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

View solution in original post

4 REPLIES 4
v-rzhou-msft
Community Support
Community Support

Hi  @Anonymous 

The error detail has shown the reason, 'Sales Data'[Year] is not Date type.

Is 'Sales Data'[Year] a Whole number type column with values like 2020, 2021?

Try to update your measure as below.

Measure 2:

PY Revenue = CALCULATE([CY Revenue],Filter(All(Sales Data),'Sales Data'[Year] = MAX('Sales Data'[Year])-1))

 

Best Regards,

Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. 

Pragati11
Super User
Super User

Hi @Anonymous ,

 

What is the data-type of your column 'Sales Data'[Year] ???

 

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

Anonymous
Not applicable

Thanks for response.

Have converting datetime field into year in SQL like bellow.

YEAR([Order Date]) [Year]

Hi @Anonymous ,

 

SAMEPERIODLASTYEAR takes date column as input, but you are just giving it year part of your date.

Check details here:

https://docs.microsoft.com/en-us/dax/sameperiodlastyear-function-dax

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

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.