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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
KIT_LKN
Frequent Visitor

Measure to count rows in 1 column in matrix, based on slicer selection

Got matrix, displaying columns/values filtered by slicer "Rapportdato" (can hold up to 12 options pr year). Except for 1 column "MEASURE pr YEAR", where I want to count values based on whole year - but still only by using the same slicer.

So, in Query I made a column "RapportdatoAsYear", displaying YYYY, based on column "Rapportdato" (holds only 1 option pr year). Then I made a measure, and put it in as column in my matrix. But it don't work quite as I had hoped... When top IF-code is for the 2023-year, I get correct 2023-data in column "MEASURE pr YEAR". But then I get no data when I change slicer to one of two options for 2022. 

If I change measure, and put 2022-year in the top IF-part, I get correct column-data when using both the two slicer options for 2022, but no data when I choose 2023-option. Anyone that can help me out here?

In query "Rapportdato" is formatted as "date", and "RapportdatoAsYear" as "Whole number". Tried change both to text, but no cigar.

 

MEASURE pr YEAR = 

    IF( 
        ISFILTERED(Table1[Rapportdato]) || RIGHT(SELECTEDVALUE(Table1[Rapportdato]), 4) = "2023",  
        CALCULATE(
            COUNT(Table1[RapportdatoAsYears]), 
            FILTER('Table1', 'Table1'[RapportdatoAsYears] = "2023")
        ), 
        
            IF(
                ISFILTERED(Table1[Rapportdato]) || RIGHT(SELECTEDVALUE(Table1[Rapportdato]), 4) = "2022",  
                CALCULATE(
                    COUNT(Table1[RapportdatoAsYears]), 
                    FILTER('Table1', 'Table1'[RapportdatoAsYears] = "2022")
            ), 
                "0"
            ) 
        )

 

KIT_LKN_0-1675512332038.png

 

 

0 REPLIES 0

Helpful resources

Announcements
October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 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.