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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

EXCEPT() not working as intended

Hi,

 

Im trying to determine a list of customers who ordered last year but not this year, and get the PnL loss from it.

 

For calculating the actual list of customers, formula is working fine:

 

 

Non reco_# = 
VAR YAG = SUMMARIZE(
    CALCULATETABLE(
        Overview,
        ALL('Date'[Date]),
        SAMEPERIODLASTYEAR('Date'[Date])
    ),
    Overview[Customer]
)
VAR CurrentFiscal = SUMMARIZE(
    Overview,
    Overview[Customer]
)
RETURN
COUNTROWS(EXCEPT(YAG,CurrentFiscal))

 

 

 

However, for calculating the PnL impact, using this formula

 

 

 

Non reco_€ = 
VAR YAG = SUMMARIZE(
    CALCULATETABLE(
        Overview,
        --ALL('Date'[Date]),
        SAMEPERIODLASTYEAR('Date'[Date])
    ),
    Overview[Customer],
    "NISx", SUM(Overview[Net Invoice Sales])
)
VAR CurrentFiscal = SUMMARIZE(
    Overview,
    Overview[Customer],
    "NISx", SUM(Overview[Net Invoice Sales])
)
RETURN
SUMX(EXCEPT(YAG,CurrentFiscal),[NISx])

 

 

 

I then get the PnL for both clients who ordered last year and not this year (what i want), but also for clients who ordered BOTH years... despite using EXCEPT...

 

Any clue why?

 

Thanks in advance !

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

As I couldnt sum with Except, i found this turnaround that works:

 

Non reco_€ = 
VAR YAG = SUMMARIZE(
    CALCULATETABLE(
        Overview,
        SAMEPERIODLASTYEAR('Date'[Date])
    ),
    Overview[Customer]
)
VAR CurrentFiscal = SUMMARIZE(
    Overview,
    Overview[Customer]
)
VAR NonReco = EXCEPT(YAG,CurrentFiscal)
RETURN
CALCULATE(
    SUM(Overview[Net Invoice Sales]),
    FILTER(NonReco, Overview[Customer]),
    SAMEPERIODLASTYEAR('Date'[Date])    
)

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@Anonymous , is there any date selected on your page or calendar ending this year.

Make sure date is there so that it takes the correct value of this and last year

 

Or like datesytd like given in the example

This Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(ENDOFYEAR('Date'[Date]),"12/31"))
Last YTD complete Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(ENDOFYEAR(dateadd('Date'[Date],-1,Year)),"12/31"))
Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Hi @amitchandak ,

 

This is a slicer on my page, with a whole fiscal year selected (for my company, going from 01/07/2019 to 30/06/2020).

As explained, formula for number of clients who didnt order works fine with this setup, it just bugs when i want the € amount linked to those customers. Please see below a screenshot: (NIS YAG refers to Net Invoice Sales for Year AGo, while Net Invoice Sales is just the PnL for this year, as the slicer allows me to display it without the need of a measure)

 

Capture.PNG

Anonymous
Not applicable

As I couldnt sum with Except, i found this turnaround that works:

 

Non reco_€ = 
VAR YAG = SUMMARIZE(
    CALCULATETABLE(
        Overview,
        SAMEPERIODLASTYEAR('Date'[Date])
    ),
    Overview[Customer]
)
VAR CurrentFiscal = SUMMARIZE(
    Overview,
    Overview[Customer]
)
VAR NonReco = EXCEPT(YAG,CurrentFiscal)
RETURN
CALCULATE(
    SUM(Overview[Net Invoice Sales]),
    FILTER(NonReco, Overview[Customer]),
    SAMEPERIODLASTYEAR('Date'[Date])    
)

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors