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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Spartanos
Helper II
Helper II

Countifs in DAX

Hi,

 

I want to calculate the countifs on time and to late per country, per tracking nr and per week. Next, I would like to calculate a % of being on time per week and per country.

 

Current data                                                                                                 

Tracking            On-time-check          week        country                             

11222                 yes                           14            DE                                     

11222                 no                            14            DE                                      

11232                 yes                           14            SE                                       

11232                 no                            14            SE

 

Desired outcome
Tracking week country performace

11222    14      DE         50%

11232    14      SE         50%

1 ACCEPTED SOLUTION
v-yanjiang-msft
Community Support
Community Support

Hi @Spartanos ,

According to your description, here's my solution.

Create a measure.

 

Performance =
VAR _CY =
    COUNTROWS (
        FILTER (
            ALL ( 'Table' ),
            'Table'[Tracking] = MAX ( 'Table'[Tracking] )
                && 'Table'[Week] = MAX ( 'Table'[Week] )
                && 'Table'[Country] = MAX ( 'Table'[Country] )
                && 'Table'[On-time-check] = "yes"
        )
    )
VAR _C =
    COUNTROWS (
        FILTER (
            ALL ( 'Table' ),
            'Table'[Tracking] = MAX ( 'Table'[Tracking] )
                && 'Table'[Week] = MAX ( 'Table'[Week] )
                && 'Table'[Country] = MAX ( 'Table'[Country] )
        )
    )
RETURN
    DIVIDE ( _CY, _C )

 

Get the correct result.

vkalyjmsft_0-1650423330803.png

I attach my sample below for reference.

 

Best Regards,
Community Support Team _ kalyj

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

2 REPLIES 2
v-yanjiang-msft
Community Support
Community Support

Hi @Spartanos ,

According to your description, here's my solution.

Create a measure.

 

Performance =
VAR _CY =
    COUNTROWS (
        FILTER (
            ALL ( 'Table' ),
            'Table'[Tracking] = MAX ( 'Table'[Tracking] )
                && 'Table'[Week] = MAX ( 'Table'[Week] )
                && 'Table'[Country] = MAX ( 'Table'[Country] )
                && 'Table'[On-time-check] = "yes"
        )
    )
VAR _C =
    COUNTROWS (
        FILTER (
            ALL ( 'Table' ),
            'Table'[Tracking] = MAX ( 'Table'[Tracking] )
                && 'Table'[Week] = MAX ( 'Table'[Week] )
                && 'Table'[Country] = MAX ( 'Table'[Country] )
        )
    )
RETURN
    DIVIDE ( _CY, _C )

 

Get the correct result.

vkalyjmsft_0-1650423330803.png

I attach my sample below for reference.

 

Best Regards,
Community Support Team _ kalyj

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

 

Greg_Deckler
Community Champion
Community Champion

@Spartanos 

COUNTX(FILTER(...)...) or CALCULATE(COUNT(),FILTER(...))

(1) CO-CU Excel to DAX Translation - Microsoft Power BI Community



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.