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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register 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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.