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
tmanoharan
Regular Visitor

Same week last year measure

Hi,

I have created a measure for same week last year sales using the formula 

Sales SWLY = CALCULATE([Sales], FILTER(ALL('DimDate'), 'DimDate'[Year]=SELECTEDVALUE('DimDate'[Year])-1&& 'DimDate'[Week No]=SELECTEDVALUE('DimDate'[Week No]))).
 
When I try to bring the measure inside my table, I'm getting a error message stating that,

 

Error Message:
MdxScript(Model) (12, 83) Calculation error in measure 'vw_BUM_TM_Sitename'[Sales SWLY]: DAX comparison operations do not support comparing values of type Text with values of type Number. Consider using the VALUE or FORMAT function to convert one of the values.

 

3 REPLIES 3
Anonymous
Not applicable

Found a simple solution!

 

Using the DATEADD function I am able to subtract 364 days instead of the full 365 which ensure the calculation happens accurately. We are on a 52 week fiscal year which is 364 days or 28 days over 13 periods.

 

Thanks all for your contributions which inspired my solution.

 

Michael

Cmcmahan
Resident Rockstar
Resident Rockstar

I'm guessing for whatever reason, your Year is stored as text instead of as a number value.  The [Year]-1 could be causing a conversion and then the error.

 

Check to make sure that Year and WeekNo are all numerical format.

Hi Cmcmahan,

 

You are absolutely right. The calendar table which I use has text format for year and week no. As soon as I changed that to whole numbers, I'm getting my results.

 

Thanks a lot. 

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.