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
HChoice
Frequent Visitor

An argument of function 'DATE' has the wrong data type...

I know there are heaps of similar posts and I promise I've tried different solutions, but for the life of me, I can't work out what I'm doing wrong.

 

I'm attempting to calculate the increase in median price over 20 years. The data will be updated quarterly, so I need to use dynamic dates.

 

The calc works fine in as far as I can get results and graph it, but the moment I try to apply filters to the visual in any way, I get the 'DATE' has the wrong data type error displaying in the visual.

 

20yr Increase =
VAR mdate = MAX('Quarterly Rent'[Quarter Ending])
VAR ndate = DATE(YEAR(mdate) - 20, MONTH(mdate), DAY(mdate))
VAR pay1 = CALCULATE(MIN('Quarterly Rent'[Median]),
FILTER('Quarterly Rent', 'Quarterly Rent'[Quarter Ending] = ndate))
VAR pay2 = CALCULATE(MIN('Quarterly Rent'[Median]),
FILTER('Quarterly Rent', 'Quarterly Rent'[Quarter Ending] = mdate))

RETURN DIVIDE(pay2 - pay1, pay1)
 
Thoughts? Ideas?
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@HChoice , I am assuming Quarter Ending has datatype date and if so measure looks correct.

 

Need to check what you are adding to visual, because max will work on row context

 

you can try

VAR mdate = MAXX(allselected('Quarterly Rent') , 'Quarterly Rent'[Quarter Ending])

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@HChoice , I am assuming Quarter Ending has datatype date and if so measure looks correct.

 

Need to check what you are adding to visual, because max will work on row context

 

you can try

VAR mdate = MAXX(allselected('Quarterly Rent') , 'Quarterly Rent'[Quarter Ending])

Thank you!! Sorry for the exceptionally late reply. I'm not entirely sure why it works, but I'll take it.

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.