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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

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
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.