Home > OS >  How do you filter a date table based on two separate date filters in PowerBI?
How do you filter a date table based on two separate date filters in PowerBI?

Time:07-25

I have 3 tables StartDateSelect EndDateSelect and Date. Date is what is driving my other table in the report. enter image description here

Note Date3 is formatted as 123ABC to show "Latest" for the latest date after refresh else show Date. This is to make sure that for each scheduled refresh, I will always have the filters show as the latest date so the user doesn't have to switch it each day.

In my dashboard, I have two filters for date selection (start and End). I have selected the dates I want as shown: enter image description here

I want the Dates table to be filtered for values BETWEEN the selected Start Date and Selected End Date (which in most cases will be stuck on "Latest")

I've played with filters on visuals and index columns with no luck, and I can't seem to get this to work. Or if there's another way to do this. The Between filter won't work with a word called "Latest" in it as it's ABC123 format by default.

CodePudding user response:

Create a measure as follows.

Measure = 
VAR cursor = MAX('Date'[Dates])
VAR startDate = MAX(StartDatesSelect[Dates])
VAR endDate = MAX(EndDateSelect[Dates])

RETURN IF(cursor IN DATESBETWEEN('Date'[Dates], startDate, endDate),1,0) 

Set a filter on your visual as follows:

enter image description here

That's it.

enter image description here

  • Related