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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
moesteez
Helper I
Helper I

Variables in the date function

Hi all,

 

Im trying to pass a date into a calculated dax measure but for some reason Im getting a blank value everytime.

 

This is what I have so far:

 

VAR year = YEAR(FIRSTDATE('Calendar 2'[Date]))
VAR month = MONTH(FIRSTDATE('Calendar 2'[Date]))
VAR day = DAY(FIRSTDATE('Calendar 2'[Date]))
 
Ive tested each of these variables and they are returning the correct year, month and day respectively. But when I use them in the next step:
 
CALCULATE([Quantity], 'Calendar'[Date] = DATE(year, month , day ) )
 
I get a blank value. If I swap out the variables for my own text the measure works fine. Am I doing something wrong here?
 
Thanks
 
4 REPLIES 4
moesteez
Helper I
Helper I

When i call the _min variable I get the correct date. So that part is working fine.

Hi,  @moesteez 

I suspect that the problem lies mainly in your [quantity].

You can consider directly replacing [quantity] with the complete formula.

 

Best Regards,
Community Support Team _ Eason

amitchandak
Super User
Super User

@moesteez , Can you try the min date?

 

 

Measure =
VAR _min = Minx(allselected('Calendar 2'), 'Calendar 2'[Date]))
return
CALCULATE([Quantity], filter('Calendar', 'Calendar'[Date] = _min ))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thanks @amitchandak , but this also returns a blank value for me. Im not sure why because in theory this should work

Helpful resources

Announcements
Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.