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
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
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.