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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
July 2024 Power BI Update

Power BI Monthly Update - July 2024

Check out the July 2024 Power BI update to learn about new features.

July Newsletter

Fabric Community Update - July 2024

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