cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

Calendar Table That Takes Minimum and Maximum of a Column across Multiple Tables

Hello,

 

 

I have six tables which all contain a "RecordActiveFrom" datetime column. I'm trying to create a calendar table which uses the minimum value of all of the RecordActiveFroms as the startdate and the maximum value of all of the RecordActiveFroms as the end date.

 

I have tried editing the calendar table code in the advanced editor to take a StartDate that looks similar to "List.Min(Table1[RecordActiveFrom], Table2[RecordActiveFrom], Table3[RecordActiveFrom])" and List.Max for the maximum value but this has returned a number of different errors with date formatting and invalid values.

 

I have also tried creating a nested MIN function on a calculated column but again ran into some issues.

 

Does anyone have an efficient solution which could be used for this?

4 REPLIES 4
Highlighted
Super User IV
Super User IV

Re: Calendar Table That Takes Minimum and Maximum of a Column across Multiple Tables

I believe that you should just be able to use the DAX CALENDARAUTO function for this. My understanding of CALENDARAUTO is that it creates a calendar table by looking at the dates in the data model and creates a calendar table based upon those dates.


---------------------------------------

Putting square pegs in round holes since 1972.

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Highlighted
Frequent Visitor

Re: Calendar Table That Takes Minimum and Maximum of a Column across Multiple Tables

I think this would work but my model includes other datetime columns aside from RecordActiveFrom that I don't want to calculate the minimum or maximum for. I believe CALENDARAUTO would factor in those dates making my date range larger than needed.

Highlighted
Responsive Resident
Responsive Resident

Re: Calendar Table That Takes Minimum and Maximum of a Column across Multiple Tables

The calendar DAX function will work to generate a Dates table if you can get the data into a correct Date format.

 

Date Table = CALENDAR(min('Billing Data'[Date]),max('Billing Data'[Date]))

 

I think there in lies your problem. If all of your RecordActiveFrom fields are not valid Date field, then you are going to have a problem.

 

My approach would be:

 

1) Ensure that the fields are Date (Or Date/Time) type.

2) Create measures with the minimum and maximum date fields

3) Use the CALENDAR function with the new measures. 

Highlighted
Helper III
Helper III

Re: Calendar Table That Takes Minimum and Maximum of a Column across Multiple Tables

Hello @Greg_Deckler 

 

Does the calendarauto get bigger if we add new data out of the calendarauto?

 

For example mine begins in 2018 but I will receive data from 2016 and don't know that will happen.

 

Thank you very much,

 

DM

Helpful resources

Announcements
Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Using the Community

Using the Community

Need help with the Power BI Community? Our 'Using the Community' support articles are a great place to start.

Community Summit North America

Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications

Power Platform 2020 release wave 2 plan

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors