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

HOW CAN I CREATE A DYNAMIC DATE TABLE FROM AN EXISTING DATE TABLE IN MY MODEL

Hi,

I have a line graph to create and need it to show total of 3 years back from any date selected.

 

The data will also be filterable afterwards. 

 

I need to create a seperate date table from an existing date table to use as a filter for the line graph.

 

How can achieve this such that the new date table is dynamic ie. minimum date is 3 years before maximum date of original table and the maximum is the maximum selected date on the original date table

1 ACCEPTED SOLUTION
ChenwuZhu_Gmail
Resolver I
Resolver I

Hi @Anonymous ,

 

If you need create a new data table you can use DAX CALENDAR(<start_date>, <end_date>)  to do that.

 

Some dax code like the following:

New date table =
VAR _MIN =
    MIN ( 'original date table'[Date] )
VAR _MAX =
    MAX ( 'original date table'[Date] )
RETURN
    CALENDAR ( DATE ( YEAR ( _MIN ), MONTH ( _MIN ), 1 ), _MAX )

 

Best regards.

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

View solution in original post

2 REPLIES 2
ChenwuZhu_Gmail
Resolver I
Resolver I

Hi @Anonymous ,

 

If you need create a new data table you can use DAX CALENDAR(<start_date>, <end_date>)  to do that.

 

Some dax code like the following:

New date table =
VAR _MIN =
    MIN ( 'original date table'[Date] )
VAR _MAX =
    MAX ( 'original date table'[Date] )
RETURN
    CALENDAR ( DATE ( YEAR ( _MIN ), MONTH ( _MIN ), 1 ), _MAX )

 

Best regards.

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

Hariharan_R
Solution Sage
Solution Sage

Hi  @Anonymous 

You no need another date table. You can get from one single date table. If you DAX filter context then it will be simple.

Ref - https://blog.enterprisedna.co/show-days-before-or-after-a-selected-date-using-power-bi/

Thanks

Hari

Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


My Blog :: YouTube Channel :: My Linkedin


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.