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
ILAN102010SH
Frequent Visitor

Creating historical table of dates

Hello, I have one table with columns ( user id, start date, end date)
Is it possible to make a new calender table that in it,
Will be the user id exactly in the range of dates between start date and end date?
How can I do it?
Your help will be very appreciated!
Best Regards,
Ilan-S
1 ACCEPTED SOLUTION
Phil_Seamark
Employee
Employee

Hi @ILAN102010SH

 

You could try the following calculated table.  In my case I have a table called 'Table4' with UserID, Start Date and End Date

 

My New Table = SELECTCOLUMNS(
                    FILTER(
			         CROSSJOIN(CALENDARAUTO() , 'Table4') ,
				        [Date] >= 'Table4'[Start Date]
				    && [Date] <= 'Table4'[End Date]
		          ),
                  "UserID" ,'Table4'[UserID] ,
                  "Date" , [Date]
                )

To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

View solution in original post

7 REPLIES 7
Phil_Seamark
Employee
Employee

Hi @ILAN102010SH

 

You could try the following calculated table.  In my case I have a table called 'Table4' with UserID, Start Date and End Date

 

My New Table = SELECTCOLUMNS(
                    FILTER(
			         CROSSJOIN(CALENDARAUTO() , 'Table4') ,
				        [Date] >= 'Table4'[Start Date]
				    && [Date] <= 'Table4'[End Date]
		          ),
                  "UserID" ,'Table4'[UserID] ,
                  "Date" , [Date]
                )

To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Hi @Phil_Seamark 

thank you very much!

I tried your solution and it's working good.

 

just one thing to say - in your solution you don't consider users with no end date,

so I added this expression to your formula.

 

&& [Date] <= 'Users'[end_date]
|| [Date] >= 'Users'[start_date]&& ISBLANK('Users'[end_date])

Nice mod! 🙂


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Thank you very much @Phil_Seamark
I'm a new beginner in Power Bi.
Could you please send me a sample of pbix file.
Regards,
Ilan-S

Hi @ILAN102010SH

 

Give this a crack

 

https://1drv.ms/u/s!AtDlC2rep7a-kHHzrvSHx2gFhl3m


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Thank you very much @Phil_Seamark.
I'll give it a try.
I let you know if it works.
Greg_Deckler
Super User
Super User

You can create a new table with the formula:

 

Table = CALENDARAUTO()

This creates a date table that autogenerates from the dates in your data model. Thus, if you created a data model with a single row from your table, you might get lucky.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.