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
Kurt_C
New Member

Using Custom Dates for Visuals based on FIltered Report Date

Hello,

 

I am new to PowerBI and have been reading through documentation and DAX trainings to learn as quickly as possible, but I have yet to find a good way to go about what I am looking to do. Any assistance is appreciated!

The intention for this report is to display 5 visualisations, namely line graphs that display information from the last 5 business days in relation to the filtered date on the report. For example, if the end user selects Tuesday as the date for the report, I want the visualisations to display data from the prior Tuesday, Wednesday, Thursday, Friday, and the Monday (day before).

 

I've tried several items, but the closest I've come is by building a nested IF statement (yes I'm aware a SWITCH would be cleaner) that does return the date I'm looking for, but when I attempt to use that as the filter for the graph, it doesn't automatically pull the information from that date, it just presents a date filter. Screenshot 1 is what the overall report looks like (you can disregard dates), screenshot 2 is the formula for the first graph, and then screenshot 3 is what the formula looks like as a filter.

 

The intention is for the report to require as minimal end user interaction as possible, so I don't want them to have to manually select the filter dates for each graph if possible. Thanks again for the assistance!

Screenshot 1:

Kurt_C_0-1685729513522.png

 

Screenshot 2:

Kurt_C_1-1685729545976.png

 

Screenshot 3:

Kurt_C_2-1685729587930.png

 

 

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

Hi @Kurt_C ,

 

According to your description, here are my steps you can follow as a solution.

(1) This is my test data. 

vtangjiemsft_0-1685933356713.png

CALENDAR = CALENDAR(DATE(2023,1,1),DATE(2023,12,31))

vtangjiemsft_1-1685933378955.png

(2) We can create a measure. 

Flag = SWITCH(TRUE(),
MAX('Table'[date])=SELECTEDVALUE('CALENDAR'[Date])-1,1,
MAX('Table'[date])=SELECTEDVALUE('CALENDAR'[Date])-2,2,
MAX('Table'[date])=SELECTEDVALUE('CALENDAR'[Date])-3,3,
MAX('Table'[date])=SELECTEDVALUE('CALENDAR'[Date])-4,4,
MAX('Table'[date])=SELECTEDVALUE('CALENDAR'[Date])-5,5)

(3) Create five line graphs, then filter the visual objects with [Flag]=1/2/3/4/5, and select different dates on the slicer without changing the visual objects again.

vtangjiemsft_2-1685933612954.pngvtangjiemsft_3-1685933747772.png

 

Best Regards,

Neeko Tang

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-tangjie-msft
Community Support
Community Support

Hi @Kurt_C ,

 

According to your description, here are my steps you can follow as a solution.

(1) This is my test data. 

vtangjiemsft_0-1685933356713.png

CALENDAR = CALENDAR(DATE(2023,1,1),DATE(2023,12,31))

vtangjiemsft_1-1685933378955.png

(2) We can create a measure. 

Flag = SWITCH(TRUE(),
MAX('Table'[date])=SELECTEDVALUE('CALENDAR'[Date])-1,1,
MAX('Table'[date])=SELECTEDVALUE('CALENDAR'[Date])-2,2,
MAX('Table'[date])=SELECTEDVALUE('CALENDAR'[Date])-3,3,
MAX('Table'[date])=SELECTEDVALUE('CALENDAR'[Date])-4,4,
MAX('Table'[date])=SELECTEDVALUE('CALENDAR'[Date])-5,5)

(3) Create five line graphs, then filter the visual objects with [Flag]=1/2/3/4/5, and select different dates on the slicer without changing the visual objects again.

vtangjiemsft_2-1685933612954.pngvtangjiemsft_3-1685933747772.png

 

Best Regards,

Neeko Tang

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

This worked great thank you. It was odd because the data didn't show until I added the date to the legend, I'll have to explore why that is. Outside of tweaking the formula to ignore weekends this was perfect. Very much appreciated!

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.

Top Solution Authors