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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

DAX to get MIN & MAX Date for a period- which doesn't change based on filters other than Date Slicer

Hello,

 

Happy New Year to All..!

I am trying to build a DAX Measure which can give the MIN & MAX Date for the selected period - for every row of the transaction table. Meaning If I select period Sept. to Nov. 2019 - the MIN Date for all the transactions falling in that period should be Sept. 01st, 2019 & the MAX date should be Nov. 30th, 2019.

 

I tried this formula, which works only till I do not select any other filter, but as soon as any new filter / slicer is selected, there are different values for each row.

 

SelectedPeriod_StartDate =
CALCULATE(
MIN(Table1[Bill Date]),
ALLSELECTED(Table1)
)
 
SelectedPeriod_EndDate =
CALCULATE(
MAX(Table1[Bill Date]),
ALLSELECTED(Table1)
)
 
Please help as to which DAX can help me to freeze the MIN & MAX Date based on the date selection, without getting affected by any other filters.

Thanks in advance.
3 REPLIES 3
amitchandak
Super User
Super User

@Anonymous , for that better, create date table join with the date of Table1.

Try measure like

minx(allselected('Date'), 'Date'[Date])
maxx(allselected('Date'), 'Date'[Date])

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

Hello @amitchandak ,

 

Thanks for your prompt reply.

 

I did as you mentioned, but when I used it in my required calculation - it is not yielding any output.

 

I am trying:

 

Sales_SelectedPeriod =

VAR DT1 = MINX(
ALLSELECTED(DimDate),
DimDate[Date]
)

VAR DT2 = MAXX(
ALLSELECTED(DimDate),
DimDate[Date]
)

RETURN

CALCULATE(
SUM(Table1[NetValue]),
FILTER(
ALL(Table 1),
AND(
Table 1[Key] = SELECTEDVALUE(Table1[Key]),
Table 1[Bill Date]
IN
DATESBETWEEN(DimDate[Date], DT1, DT2)
)
)
)
 
I am trying to get the Sales based on a Key (Combination of Customer & Material) for the selected period.
 
Can you suggest what am I missing?
 
Thanks,

@Anonymous ,Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

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

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 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.