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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
VikcyD
Frequent Visitor

Help Needed: DAX Logic to Count Sales Reps Meeting 2 Monthly Achievement Criteria

I have sales data and I'm trying to identify how many unique Sales Representatives qualify as 'winners'. A Sales Rep should be counted as a winner only if their achievement in the previous month was greater than 99.5% and their achievement in the current month is at least 94.5%. I've tried multiple approaches in DAX, but the result always returns 0. I'd appreciate help in figuring out what might be going wrong.

 

Follwoing is my Dax Code:

Sales Ach_Status_Count =
SUMX(
VALUES (SaleData[Terr_Code] ),
VAR Terr = SaleData[Terr_Code]

VAR CurrAch =
CALCULATE
(
DIVIDE([TotalSaleCYValue_INR], [Target_ValueCY_INR], 0),
SaleData[Terr_Code] = Terr,
'Calendar'[Date] = EOMONTH(MAX(SaleData[Date]), 0)
)

VAR PrevAch =
CALCULATE
(
DIVIDE([TotalSaleCYValue_INR], [Target_ValueCY_INR], 0),
SaleData[Terr_Code] = Terr,
'Calendar'[Date] = EOMONTH(MAX(SaleData[Date]), -1)
)

RETURN
IF (
CurrAch >= 0.945 && PrevAch >= 0.995,
1,
0
)
)

1 ACCEPTED SOLUTION
wardy912
Impactful Individual
Impactful Individual

Hi @VikcyD 

 

Please try this

 

Sales Ach_Status_Count =
CALCULATE (
    COUNTROWS (
        FILTER (
            VALUES ( SaleData[Terr_Code] ),
            VAR Terr = SaleData[Terr_Code]

            VAR CurrAch =
                CALCULATE (
                    DIVIDE ( [TotalSaleCYValue_INR], [Target_ValueCY_INR], 0 ),
                    FILTER (
                        ALL ( 'Calendar' ),
                        'Calendar'[Month] = MONTH ( MAX ( SaleData[Date] ) )
                            && 'Calendar'[Year] = YEAR ( MAX ( SaleData[Date] ) )
                    ),
                    SaleData[Terr_Code] = Terr
                )

            VAR PrevAch =
                CALCULATE (
                    DIVIDE ( [TotalSaleCYValue_INR], [Target_ValueCY_INR], 0 ),
                    FILTER (
                        ALL ( 'Calendar' ),
                        'Calendar'[Month] = MONTH ( EOMONTH ( MAX ( SaleData[Date] ), -1 ) )
                            && 'Calendar'[Year] = YEAR ( EOMONTH ( MAX ( SaleData[Date] ), -1 ) )
                    ),
                    SaleData[Terr_Code] = Terr
                )

            RETURN
                CurrAch >= 0.945 && PrevAch >= 0.995
        )
    )
)

 

I hope this helps, please give a thumbs up and mark as solved if it does, thanks!

View solution in original post

3 REPLIES 3
wardy912
Impactful Individual
Impactful Individual

Hi @VikcyD 

 

Please try this

 

Sales Ach_Status_Count =
CALCULATE (
    COUNTROWS (
        FILTER (
            VALUES ( SaleData[Terr_Code] ),
            VAR Terr = SaleData[Terr_Code]

            VAR CurrAch =
                CALCULATE (
                    DIVIDE ( [TotalSaleCYValue_INR], [Target_ValueCY_INR], 0 ),
                    FILTER (
                        ALL ( 'Calendar' ),
                        'Calendar'[Month] = MONTH ( MAX ( SaleData[Date] ) )
                            && 'Calendar'[Year] = YEAR ( MAX ( SaleData[Date] ) )
                    ),
                    SaleData[Terr_Code] = Terr
                )

            VAR PrevAch =
                CALCULATE (
                    DIVIDE ( [TotalSaleCYValue_INR], [Target_ValueCY_INR], 0 ),
                    FILTER (
                        ALL ( 'Calendar' ),
                        'Calendar'[Month] = MONTH ( EOMONTH ( MAX ( SaleData[Date] ), -1 ) )
                            && 'Calendar'[Year] = YEAR ( EOMONTH ( MAX ( SaleData[Date] ), -1 ) )
                    ),
                    SaleData[Terr_Code] = Terr
                )

            RETURN
                CurrAch >= 0.945 && PrevAch >= 0.995
        )
    )
)

 

I hope this helps, please give a thumbs up and mark as solved if it does, thanks!

You are amzing Thanks @wardy912 

VikcyD
Frequent Visitor

VikcyD_0-1754904564316.png

Example Caclucted in  excelExample Caclucted in excel

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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