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

Filter Date Table/SLicer

I have 3 queries that I am using to create a Project Management report.

  1. 'Spent' is a report pulled from Oracle that contains data from all projects from the last 8 years or so.  This report only includes data for money that has been invoiced or spent.
  2. 'Committed' is a report from Oracle that contains data from all projects like above, but only includes data with money that has not been spent.
  3. 'Budget' is an excel sheet that is used to define an individual projects budget and forecast data.

I built the report based on using only excel spreadsheets.  Both the 'Spent' and 'Committed' excel sheets were exported and already filtered for a specific project.  We will be updating the report to use the actual Oracle data so that we no longer have to download/export data to update the report.  In doing so, I will now need to filter the 'Spent' and 'Committed' data by Project Number.  I am doing some testing with excel sheets that contain multiple projects data.  I have successfully filtered the entire report using a Project Number slicer.  However, I now would like to filter the "timeline" filter to show only dates relevant to the project selected, not all projects in the entire Oracle database.  The "timeline" slicer is created from separate date columns from the 'Budget' and 'Spent' queries.  This date table is used to track the spend and budget/forecast over time.

 

There are existing columns that define each projects start date 'Spent'[PROJECT START DATE] and end date 'Spent'[PROJECT END DATE].  I have successfully created two measures that display the correct start date and end date for the selected project.

Start Date = 
minx(FILTER(Spent, [PROJECT] = SELECTEDVALUE('Project Table'[PROJECT])), Spent[PROJECT START DATE])
End Date = 
MAXX(FILTER(Spent, [PROJECT] = SELECTEDVALUE('Project Table'[PROJECT])), Spent[PROJECT END DATE])

 

I then tried countless variations of using these dates to create a "Project Date Table" that line up with these dates.  The simplest is below, but does not filter based on the measures, it shows the dates from every project.  Below, the 'Table'[Date] is a defined date table that starts at the beginning of the first project and ends at the last date of the last project.

Date Table = 
    DATESBETWEEN('Table'[Date], 'Spent'[Start Date], 'Spent'[End Date])

 Project number slicer.Project number slicer.Timeline slicer.Timeline slicer.Attempt at Project Dates table.Attempt at Project Dates table.Correct project end date.Correct project end date.Relationships.Relationships.Correct project start date.Correct project start date.

1 ACCEPTED SOLUTION
AllisonKennedy
Super User
Super User

You will need to create a MEASURE that finds the start and end date for each project after slicer selections. A table built using DAX will never update based on slicer selection. This is because of the order of operations in Power BI. Power BI order of operations is basically as follows:

Raw data source updates/changes
Power Query operations (M code)
DAX tables and columns
Slicers
DAX measures

When you click Refresh, it will go back to the Raw data source and check for updates, apply the query changes from Power Query, then calculate that DAX tables and columns and THEN apply the slicer selections.

If you want the DimDate table to be filtered by the project values, try adding a measure to it as a filter. Similar to this post from Reza Rad on filtering slicers with slicers:
https://radacad.com/one-dimension-filters-another-dimension-in-power-bi/?ref=818

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

View solution in original post

3 REPLIES 3
AllisonKennedy
Super User
Super User

You will need to create a MEASURE that finds the start and end date for each project after slicer selections. A table built using DAX will never update based on slicer selection. This is because of the order of operations in Power BI. Power BI order of operations is basically as follows:

Raw data source updates/changes
Power Query operations (M code)
DAX tables and columns
Slicers
DAX measures

When you click Refresh, it will go back to the Raw data source and check for updates, apply the query changes from Power Query, then calculate that DAX tables and columns and THEN apply the slicer selections.

If you want the DimDate table to be filtered by the project values, try adding a measure to it as a filter. Similar to this post from Reza Rad on filtering slicers with slicers:
https://radacad.com/one-dimension-filters-another-dimension-in-power-bi/?ref=818

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Anonymous
Not applicable

Hi Allison,

 

Thank you!!!  I should have done some more testing first.  I had the solution, but overthought it...  I thought the measure I was using would create a never ending project, as the "cumulative budget" measure will always have a value greater than 0 after project initiation.  Everything looks to work as I want though.

@Anonymous You're welcome!
Glad it's working as you want - everything seems so simple once you know the answer. 🙂

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

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.