March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hello PBI Community...
I have a question that I don’t even know is possible.
I have a report in PBI desktop and I want there to be buttons (potentially a slicer) to show the income either for last week or the year to date (YTD). Clearly last week is a subset of YTD so the two options in the slicer are not unique... is this possible or can someone come up with a work around, I’m reasonably new to PBI so don’t know all the tricks of the trade yet.
My initial work around was to have a slicer with 'last week' and 'YTD excluding last week', and people would have to use 'select all' to see the full YTD. But as I build these reports for other teams, I noticed that the team were using it incorrectly as it’s not very intuitive (they were just selecting the YTD minus last week as the full YTD).
Please help,
Thanks.
Harriet.
Solved! Go to Solution.
I'd do a disconnected table/switch combination that looks like this:
Step #1 Create a disconnected table:
Number Chooser
0 YTD
1 Last Week
Step 2 the measure
= Switch(min(DisconnectedTable[Number]),
0,[Calculation #1],
1,[Calculation #2])
Step 3. Bring the Chooser column, from the disconnected table, on to the pivot as a slicer. When you select YTD, the min will filter to 0, and the switch will run calc #1. When you select Last Week, the min will filter to 1, and the switch will run calc#2
Essentially you make two distinct calcs, one that does YTD, and another that does last week. Then the switch will toggle between them.
Does this help?
In this scenario, you can first create two measures for YTD and Last Week. Then create another new table for these two measures. So that either of the measures can be selected in the slicer and you can get the expected result.
Please refer to following steps:
YTD_Income = CALCULATE ( SUM ( Table1[Income] ), DATESYTD ( Table1[Date] ) )
LastWeek_Income = VAR LastDay = LASTDATE ( Table1[Date] ) VAR WeekDayNum = WEEKDAY ( LastDay ) RETURN ( CALCULATE ( SUM ( Table1[Income] ), FILTER ( ALL ( Table1[Date] ), Table1[Date] > LastDay - 7 - WeekDayNum && Table1[Date] <= LastDay - WeekDayNum ) ) )
Regards,
I'd do a disconnected table/switch combination that looks like this:
Step #1 Create a disconnected table:
Number Chooser
0 YTD
1 Last Week
Step 2 the measure
= Switch(min(DisconnectedTable[Number]),
0,[Calculation #1],
1,[Calculation #2])
Step 3. Bring the Chooser column, from the disconnected table, on to the pivot as a slicer. When you select YTD, the min will filter to 0, and the switch will run calc #1. When you select Last Week, the min will filter to 1, and the switch will run calc#2
Essentially you make two distinct calcs, one that does YTD, and another that does last week. Then the switch will toggle between them.
Does this help?
Thanks!
Harriet.
Hi. make a calculated column with either current week or YTD. something like:
if(now()>week_start_date, = "current_week",if(now()-365>week_start_date,"YTD","other")).
use that in your slicer and you will get either YTD or last_wk or other
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
134 | |
90 | |
90 | |
66 | |
58 |
User | Count |
---|---|
201 | |
137 | |
107 | |
70 | |
68 |