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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Returning minimum and maximum seleted dates on slicer

Hi All

 

A little bamboozled by this one.

 

I have a field [CreatedOn] that is in format dd/mm/yy hh;nn;ss and a calculated column [Created On Date] that just returns the date part of [CreatedOn] as dd/mm/yy.

I have a slicer on [Created On Date]

All I want is to identify the minimum and maximum selected dates, for display in card visuals and to use in a calculation (divide various values by number of days selected). 

I have created 2 measures;

MaxSelected = CALCULATE(max(incidents[CreatedOn].[Date]),ALLSELECTED(incidents[CreatedOn].[Date])) 

MinSelected = CALCULATE(minx(incidents[CreatedOn].[Date]),ALLSELECTED(incidents[CreatedOn].[Date]))
Both measures are only returning max and min of the unfiltered table. I have also tried just the table and table & column formats of ALLSELECTED EG ALLSELECTED(incidents) and ALLSELECTED(incidents,incidents[CreatedOn].[Date])
For testing puposes there are no other filters in play and if use earliest and latest [Created On Date] in a card visual i get the correct dates.
I thought CALCULATE(MAX(TABLE[COLUMN]),ALLSELECTED(TABLE[COLUMN])) was the right way to achieve this? What am i doing wrong?
 
1 ACCEPTED SOLUTION
TeigeGao
Solution Sage
Solution Sage

Hi @Anonymous ,

Actually, in your scenario, you only need to use the following DAX query to get the result:

MaxSelected = CALCULATE(max(incidents[Created On Date]))
MinSelected = CALCULATE(min(incidents[Created On Date]))

Assume that we have a table like below:

PBIDesktop_OlMaemqGmS.png

The result will like below:

PBIDesktop_igkRwsJuIv.png

Best Regards,

Teige

View solution in original post

2 REPLIES 2
TeigeGao
Solution Sage
Solution Sage

Hi @Anonymous ,

Actually, in your scenario, you only need to use the following DAX query to get the result:

MaxSelected = CALCULATE(max(incidents[Created On Date]))
MinSelected = CALCULATE(min(incidents[Created On Date]))

Assume that we have a table like below:

PBIDesktop_OlMaemqGmS.png

The result will like below:

PBIDesktop_igkRwsJuIv.png

Best Regards,

Teige

Anonymous
Not applicable

Teige, many thanks.

Had not tried that, but would have expected that to return min and max dates of the unfiltered table.

Every dyas a school dayCat Surprised

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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