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

How to add slicer value to filter in Union & Row Function dataset

I'm using this formula to show record in Matrix Visual 

UNION(
    ROW("Quarters","Last Quater","Number",CALCULATE(COUNT(HRSSNew[ID]),FILTER(HRSSNew,HRSSNew[Year]=YEAR(UTCTODAY())-1 && HRSSNew[QuarterNo] = 4 && HRSSNew[ProcessType] = "Reports"))),
    ROW("Quarters","Quater 1","Number",CALCULATE(COUNT(HRSSNew[ID]),FILTER(HRSSNew,HRSSNew[Year]=YEAR(TODAY()) && HRSSNew[QuarterNo] = 1 && HRSSNew[ProcessType] = "Reports"))),
           
    ROW("Quarters","Quater 2","Number",CALCULATE(COUNT(HRSSNew[ID]),FILTER(HRSSNew,HRSSNew[Year]=YEAR(TODAY()) && HRSSNew[QuarterNo] = 2 &&HRSSNew[ProcessType] = "Reports"))),
           
            ROW("Quarters","Quater 3","Number",CALCULATE(COUNT(HRSSNew[ID]),FILTER(HRSSNew,HRSSNew[Year]=YEAR(TODAY()) && HRSSNew[QuarterNo] = 3 && HRSSNew[ProcessType] = "Reports"))),
           
            ROW("Quarters","Quater 4","Number",CALCULATE(COUNT(HRSSNew[ID]),FILTER(HRSSNew,HRSSNew[Year]=YEAR(TODAY()) && HRSSNew[QuarterNo] = 4 && HRSSNew[ProcessType] = "Reports"))      
            ))

This is static value but user want to filter the record based on Year Slicer Selected ?
Also they want the default slicer to be currect year.
Anyone who has done this before ?
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @chintusasmal123 ,

It appears that you are trying to create a calculated table. As a calculated table, its values will not be affected by user interactions such as slicers and filters. Please follow the steps outlined below to get the expected table:

1. Create a year dimension table (Do not create any relationship with the table 'HRSSNew')

vyiruanmsft_1-1716451446088.png

2. Create a slicer which apply the field [Year] of the above dimension table

3. Create a measure as below 

Number = 
VAR _year =
    SELECTEDVALUE ( 'Year'[Year] ,YEAR(TODAY()))
VAR _count =
    CALCULATE (
        COUNT ( HRSSNew[ID] ),
        FILTER (
            HRSSNew,
            ( HRSSNew[Year] = _year
                || ( HRSSNew[Year] = _year - 1
                && HRSSNew[QuarterNo] = 4 ) )
                && HRSSNew[ProcessType] = "Reports"
        )
    )
RETURN
    _count

vyiruanmsft_0-1716451316571.png

Best Regards

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @chintusasmal123 ,

It appears that you are trying to create a calculated table. As a calculated table, its values will not be affected by user interactions such as slicers and filters. Please follow the steps outlined below to get the expected table:

1. Create a year dimension table (Do not create any relationship with the table 'HRSSNew')

vyiruanmsft_1-1716451446088.png

2. Create a slicer which apply the field [Year] of the above dimension table

3. Create a measure as below 

Number = 
VAR _year =
    SELECTEDVALUE ( 'Year'[Year] ,YEAR(TODAY()))
VAR _count =
    CALCULATE (
        COUNT ( HRSSNew[ID] ),
        FILTER (
            HRSSNew,
            ( HRSSNew[Year] = _year
                || ( HRSSNew[Year] = _year - 1
                && HRSSNew[QuarterNo] = 4 ) )
                && HRSSNew[ProcessType] = "Reports"
        )
    )
RETURN
    _count

vyiruanmsft_0-1716451316571.png

Best Regards

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.