Forum Discussion
Need help on Slicer interaction
- 8 months ago
Hi MAruna
Are you looking for an output similar to this ?
If this is what you are looking for , please create a Year option table and include the three dax measure in the pbix file I have attached
Hi MAruna,
You can do this in Power BI by creating one slicer table and one measure that shows the amount based on what you select.
Step 1: Create a slicer table
Create a new table:
YearSelector =
DATATABLE(
"Selection", STRING,
{
{ "Current Year" },
{ "Previous Year" },
{ "Financial Year" }
}
)
Use YearSelector[Selection] in the slicer.
Step 2: Create the final measure
This measure checks what you selected in the slicer and shows the correct amount:
Amount Output =
VAR Sel = SELECTEDVALUE(YearSelector[Selection])
VAR CY = CALCULATE([Amount], 'Date'[Year] = 2023) -- your current year
VAR PY = CALCULATE([Amount], 'Date'[Year] = 2022) -- your previous year
RETURN
SWITCH(
Sel,
"Current Year", CY,
"Previous Year", CY + PY,
"Financial Year", CY + PY
)
If you choose Current Year, it shows only current year amount.
If you choose Previous Year, it shows previous year + current year.
If you choose Financial Year, it shows both years together (2022–23).