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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

How to create a dynamic DateDimension based on FromDate and ToDate in multiple selection

I need some way to filter out dates from a date dimension, and consequently items in a fact table connected to that date dimension, based on a calculated date-span. The user will select one or more periods (the periods are predefined since they are timeperiods when a certain condition was applied to the facts in the fact table) (the user will select for instance 2018-11-01 to 2018-11-04 and 2018-11-13 to 2018-11-18 retrieved from two columns in the filter table (FromDate and ToDate) and then I want to compare the number of items in the fact table during (2018-11-01 to 2018-11-18 (19 days)) to the period before that (2018-10-13 to 2018-10-31 (also 19 days)).

I can create measures that calculates the start and end-dates for both periods and then create a measure that counts the number of facts in each period and slice that in a graph based on Year/Month/Date but i need to show every date from each period in the graph. Since the measure i calculated only counts occurances in the fact table I dont get any matches on dates where there where no facts. I believe I need to create a dynamic DateDimension that would contain the dates for the first selected periods and then another date-dimension that would contain the dates from the period before and then use those dimensions in my graph. Is it possible to create a dynamic table based on a calculated measure like this and if so, how could I do that?

 

 

Actually... what I actully want to do is to compare only the four days in the selected period to the matching four days in the previous period and the next six days in the last period and so on if the user has selected more then two periods, but that is the next step... If I can figure out how to do the first filtering described above I hope I can use that solution to do this second filtering.

 

Thanks in advance!

1 ACCEPTED SOLUTION
v-chuncz-msft
Community Support
Community Support

@Anonymous,

 

You may drag date from a separate calendar table, apply virtual relationship in DAX measure and then take advantage of Visual level filters.

Community Support Team _ Sam Zha
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
v-chuncz-msft
Community Support
Community Support

@Anonymous,

 

You may drag date from a separate calendar table, apply virtual relationship in DAX measure and then take advantage of Visual level filters.

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Thankyou for your reply. I managed to solve the first part of my problem according to your suggestions but I still have to figure out the rest... I posted a new question with an example pbix-file here:

 

https://community.powerbi.com/t5/Desktop/How-to-compare-selected-dateranges-with-calculated-period/m...

 

Thanx!

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors