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 September 15. Request your voucher.

Reply
JackWren
Helper II
Helper II

Using the output of except - Finding what's there or not

Hi, 

 

I am trying to use a switch function to classify my IDs based on their reccurence in my table. 

If the ID was present in 2021 and 2020, it's a "new 2021"

If it wasn't it is a "real new 2021"

If the ID was present in 2020 and 2019 it's a "new 2020"

If it wasn't it is a "real new 2020"

 

I have a table with my IDs and my starting date and it is linked to my calendar table which has current year flags (2021 = 0; 2020 = -1, 2019 = -2) 

 

Here is my calculated column but I have issues with the 4th line of code "New 2020" which does not return anything.

 

I tried with intersect instead because the idea was to see which ID were present in both compared years for the ones which are "new 2021 and 2020" but to no avail. 

 

CategoryCurrentYear =
Var TheseID = CALCULATETABLE(values('Table'[ID]),FILTER('DWH Calender','Calender'[CURRENT_YEAR_INDICATOR]=0))
 
Var TheseIDLastYear = CALCULATETABLE(values(' Table'[ID]),FILTER('DWH Calender','DWH Calender'[CURRENT_YEAR_INDICATOR]=-1))
 
Var TheseIDTheYearBeforelastYear = CALCULATETABLE(values('Table'[ID]),FILTER('DWH Calender','DWH Calender'[CURRENT_YEAR_INDICATOR]=-2))
 
RETURN
Switch(
True(),
COUNTROWS(EXCEPT(TheseID,TheseIDLastYear))=1,"RealNew2021",
COUNTROWS(EXCEPT(TheseIDLastYear,TheseIDTheYearBeforelastYear))=1,"RealNew2020",
COUNTROWS(EXCEPT(TheseID,TheseIDLastYear))=0,"New2021",
COUNTROWS(EXCEPT(TheseIDLastYear,TheseIDTheYearBeforelastYear))=0,"New2020",
blank()
)

 

Thanks

Jack

 

2 REPLIES 2
Greg_Deckler
Community Champion
Community Champion

@JackWren Sample data would help but I *think* countrows of blank is going to be blank, not 0 so that might be the problem?

 

Otherwise, Sorry, having trouble following, can you post sample data as text and expected output?
Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.



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

Sorry, 

 

Here is the sample data 

 

DateID
01/02/2021AAA
16/03/2020AAA
01/12/2020BB
20/04/2015BB
08/10/2021CC
14/07/2019DD
12/05/2020DD

 

 

Results

 

AAANew 2021
BBReal New 2020
CCReal New 2021
DDNew 2020

 

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.