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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
vespa
Regular Visitor

Help Dax Distinct

Hi

 

I have 2 measures : Turnover and Last Year Turnover

 

I want to have a measure in dax

 

Distinct customer who have turnover this year but not last year

Disctinct customer who have turnover last year but not this year

 

I try

 

CALCULATE (
    DISTINCTCOUNT(  '_Sales'[Customer] ),
    FILTER( '_Sales'   ,   '_Sales'[Turnover] > 0 && '_Sales'[TurnoverLastYear] = 0 )  
)
 
But it's not working, thank you in advance for your help 

 

4 REPLIES 4
vespa
Regular Visitor

Thank you very much, this clearly shows me the results for this year and last year.

How can I modify it so that it works for each year and its previous year? whether it is dynamic?

thanks in advance

Hi, @vespa 

in @Jihwan_Kim code modify like below

var _currentyear= selectedvalue(datetablename[yearcolumn])

to be more dynamic is it possible to use something to get current period et same period last year ?

Jihwan_Kim
Super User
Super User

Hi, I am not sure if I understood your question correctly, but I tried to create a sample pbix file like below.

please check the below picture and the attached pbix file if it suits your requirement.

 

Jihwan_Kim_1-1703176257951.png

 

 

Jihwan_Kim_0-1703176225658.png

 

EXCEPT function (DAX) - DAX | Microsoft Learn

 

Only this year customers count: = 
VAR _currentyear =
    YEAR ( TODAY () )
VAR _lastyear = _currentyear - 1
VAR _thisyearlist =
    CALCULATETABLE (
        SUMMARIZE ( Sales, Customer[Customer] ),
        'Calendar'[Year] = _currentyear
    )
VAR _prevyearlist =
    CALCULATETABLE (
        SUMMARIZE ( Sales, Customer[Customer] ),
        'Calendar'[Year] = _lastyear
    )
VAR _onlythisyearlist =
    EXCEPT ( _thisyearlist, _prevyearlist )
RETURN
    CALCULATE ( COUNTROWS ( Customer ), _onlythisyearlist )
Only previous year customers count: = 
VAR _currentyear =
    YEAR ( TODAY () )
VAR _lastyear = _currentyear - 1
VAR _thisyearlist =
    CALCULATETABLE (
        SUMMARIZE ( Sales, Customer[Customer] ),
        'Calendar'[Year] = _currentyear
    )
VAR _prevyearlist =
    CALCULATETABLE (
        SUMMARIZE ( Sales, Customer[Customer] ),
        'Calendar'[Year] = _lastyear
    )
VAR _onlypreviousyearlist =
    EXCEPT ( _prevyearlist, _thisyearlist )
RETURN
    CALCULATE ( COUNTROWS ( Customer ), _onlypreviousyearlist )

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.