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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. 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
v-yiruan-msft
Community Support
Community Support

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

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-yiruan-msft
Community Support
Community Support

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

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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