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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Automatically fixing a date in measure?

Hi,

 

I had a rather lengthy post yesterday that for some reason disappeared and which I do intend to repost, but I had a question regarding using dates within a filter.  Consider the following measure:

 

DQ 2019 Benchmark = CALCULATE([DQ Rate 2PY (Forecast)],
                                                          STARTOFMONTH(dimDate[Date]))
                                   - CALCULATE([dq_ar_switch] / [$ CY AR],
                                                         STARTOFMONTH(dimDate[Date]))
 
The STARTOFMONTH function fixes the date at the beginning of the month for whichever date range is shown on the chart.  But what if I add a date slider and begin my chart at, say, the 4th or 5th of the month instead of the 1st?  Is there anyway that I can create a filter which will automatically detect the minimum possible date in the chart, and have that date be fixed similar to using something like the STARTOFMONTH function above?
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , Min date in selection /visual

DQ 2019 Benchmark =
var _min = minx(allselected(dimDate), dimDate[Date])
return
CALCULATE([DQ Rate 2PY (Forecast)],filter(dimDate,dimDate[Date] = _min )) - CALCULATE(divide([dq_ar_switch] , [$ CY AR]),filter(dimDate,dimDate[Date] = _min ))

or

 

First date each month

DQ 2019 Benchmark =

CALCULATE([DQ Rate 2PY (Forecast)],filter(dimDate,dimDate[Date] = eomonth( dimDate[Date],-1)+1 )) - CALCULATE(divide([dq_ar_switch] , [$ CY AR]),filter(dimDate,dimDate[Date] = eomonth( dimDate[Date],-1)+1 ))

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

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous , Min date in selection /visual

DQ 2019 Benchmark =
var _min = minx(allselected(dimDate), dimDate[Date])
return
CALCULATE([DQ Rate 2PY (Forecast)],filter(dimDate,dimDate[Date] = _min )) - CALCULATE(divide([dq_ar_switch] , [$ CY AR]),filter(dimDate,dimDate[Date] = _min ))

or

 

First date each month

DQ 2019 Benchmark =

CALCULATE([DQ Rate 2PY (Forecast)],filter(dimDate,dimDate[Date] = eomonth( dimDate[Date],-1)+1 )) - CALCULATE(divide([dq_ar_switch] , [$ CY AR]),filter(dimDate,dimDate[Date] = eomonth( dimDate[Date],-1)+1 ))

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

Thank you!  Using this portion solved my issue completely:

 

var _min = minx(allselected(dimDate), dimDate[Date])

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.