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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Anonymous
Not applicable

Date Selection with Slicer

Hello, 

I have a data set with date such as Jun 1 - Yesterday, I would like to have a slicer with two option, Yesterday / MTD.

 

How could I do that?

 

Thanks!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

@Anonymous,

Do you want to use a slicer to choose which measure(Yesterday or MTD) to display? If so, create a new table containing the measure name like below.
1.PNG

Then create the following similar measures in your original table, please note that there is no relationship between the new table and your original table.

salesMTD = TOTALMTD(SUM(Table6[Amount]),Table6[Date])
salesYesterday = CALCULATE(SUM(Table6[Amount]),FILTER(Table6,Table6[Date]=TODAY()-1))
selected measure1 = IF(HASONEVALUE(Table7[Measure]),SWITCH(FIRSTNONBLANK(Table7[Measure],Table7[Measure]),"Yesterday",[salesYesterday],"MTD",[salesMTD]),blank())

Reference:

http://breaking-bi.blogspot.sg/2016/06/power-bipowerpivot-using-slicers-to.html

Regards,
Lydia Zhang

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

@Anonymous,

Do you want to use a slicer to choose which measure(Yesterday or MTD) to display? If so, create a new table containing the measure name like below.
1.PNG

Then create the following similar measures in your original table, please note that there is no relationship between the new table and your original table.

salesMTD = TOTALMTD(SUM(Table6[Amount]),Table6[Date])
salesYesterday = CALCULATE(SUM(Table6[Amount]),FILTER(Table6,Table6[Date]=TODAY()-1))
selected measure1 = IF(HASONEVALUE(Table7[Measure]),SWITCH(FIRSTNONBLANK(Table7[Measure],Table7[Measure]),"Yesterday",[salesYesterday],"MTD",[salesMTD]),blank())

Reference:

http://breaking-bi.blogspot.sg/2016/06/power-bipowerpivot-using-slicers-to.html

Regards,
Lydia Zhang

cs_skit
Resolver IV
Resolver IV

quick and dirty use calculated column with SWITCH or IF

 

not that beautiful though but if the data refreshes regularly and the refresh performance isnt an issue thats fine

if you dont want that build good time intelligence for your model theres tutorials

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.