cancel
Showing results for
Did you mean:
Helper II

## Calculating Min/Max date columns based on selected values

Hi,

I am trying to insert 2 new columns into my dataset containing the MIN/MAX values of the date slicer.

I was thinking about the following DAX, but it throws me a circular dependency error.

```Min selected date (ALLSELECTED) =
CALCULATE( MIN('Calendar'[Date]), ALLSELECTED('Calendar'[Date]) )```

Appreciate if anyone would have an idea.

Here is the pbix file:

1 ACCEPTED SOLUTION
Super User III

Hi,

You have to write measures, not calculated column formulas.  Delete all column from the Calendar Table except the Date column.  Write these measures

Minimum date = CALCULATE(MIN('Calendar'[Date]),ALLSELECTED('Calendar'[Date]))

Maximum date = CALCULATE(MAX('Calendar'[Date]),ALLSELECTED('Calendar'[Date]))

Hope this helps.

Regards,
Ashish Mathur
http://www.ashishmathur.com
6 REPLIES 6
Community Champion

Hi @Maikeru

Try the following as columns

MinDate = CALCULATE( MIN('01-MasterCalendar'[Date]),
FILTER(ALL('01-MasterCalendar'[Date]),'01-MasterCalendar'[Year] =YEAR('01-MasterCalendar'[Date]) ))

MaxDate = CALCULATE( Max('01-MasterCalendar'[Date]),
FILTER(ALL('01-MasterCalendar'[Date]),'01-MasterCalendar'[Year] =YEAR('01-MasterCalendar'[Date]) ))

Replace '01-MasterCalendar' with your calendar table name.

Using these expressions it will generate MIn and Max dates for each year in the calendar table.

If this works for you please accept this as solution and also give KUDOS.

Cheers

CheenuSing

Did I answer your question? Mark my post as a solution and also give KUDOS !

Proud to be a Datanaut!
Super User III

Hi,

You have to write measures, not calculated column formulas.  Delete all column from the Calendar Table except the Date column.  Write these measures

Minimum date = CALCULATE(MIN('Calendar'[Date]),ALLSELECTED('Calendar'[Date]))

Maximum date = CALCULATE(MAX('Calendar'[Date]),ALLSELECTED('Calendar'[Date]))

Hope this helps.

Regards,
Ashish Mathur
http://www.ashishmathur.com
New Member

Hi @Ashish_Mathur , is it possible have this as a column?

im saying this because im using a Matrix table so it doesnt allow measures in the rows.

Super User III

Hi,

Switch to a matrix visual and in the formatting pane, under the Values group, turn on Show on rows.

Regards,
Ashish Mathur
http://www.ashishmathur.com
Helper II

Thank you @Ashish_Mathur!
That's exactly what I was looking for!

Super User III

You are welcome.

Regards,
Ashish Mathur
http://www.ashishmathur.com

Announcements

#### 2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

#### Microsoft named a Leader in The Forrester Wave

Microsoft received the highest score of any vendor in both the strategy and current offering categories.

#### Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Top Solution Authors
Top Kudoed Authors