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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Roy_tap
Helper I
Helper I

How to apply Countif based on measure value

Hi,

 

I have currently 2 tables as follows
Table 1 (Multiple Side filter apply to get the measure value)

YearResourceMeasure Value
2024A1
2024B2
2024C0
2024D0
2024E3
2024F2


Table 2 (Same Multiple Side will be apply to get the measure (Countif) value)

Value (Static Value from 0 - 10m Measure value in table 1 will only be 0 - 10)Measure (Countif)
02
11
22
31


How can I get the measure (Countif) based on the Resource count. 

Thanks

1 ACCEPTED SOLUTION

The measure is not returning anything. i am actually having a complex measure that doesnt reside inside Table 1, so i need to use calculatetable to store the Resource and Measure within the same object before countx.  

    var _Value = SELECTEDVALUE('Table 2'[Column1])

    RETURN
        COUNTX(
            CALCULATETABLE(
            FILTER(VALUES('Table 1'[Resource]),
            [Measure Value]=_Value
            )),
        [Measure value]
        )

Anyway thanks for the proposed solution.

View solution in original post

2 REPLIES 2
Irwan
Super User
Super User

hello @Roy_tap 

 

please check if this accomodate your need.

Irwan_0-1740019870722.png

 

since you are mentioned about measure, i assumed you want to do this in measure form.

 

1. create a new measure with following DAX

Measure Countif = 
var _Value = SELECTEDVALUE('Table 2'[Column1])
Return
COUNTX(
    FILTER(
        'Table 1',
        'Table 1'[Measure Value]=_Value
    ),
    'Table 1'[Measure Value]
)
 
Hope this will help.
Thank you.

The measure is not returning anything. i am actually having a complex measure that doesnt reside inside Table 1, so i need to use calculatetable to store the Resource and Measure within the same object before countx.  

    var _Value = SELECTEDVALUE('Table 2'[Column1])

    RETURN
        COUNTX(
            CALCULATETABLE(
            FILTER(VALUES('Table 1'[Resource]),
            [Measure Value]=_Value
            )),
        [Measure value]
        )

Anyway thanks for the proposed solution.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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