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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.