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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
sparamanga
New Member

Count Distinct but ignore any values counted in prior months

Hi, Im trying to calculate a distinct count of exporters and display this on a column chart with the snapshot month on the x axis. I want to exclude the exporters already counted in previous months so that each column will add up to the total of unique exporters so far this year of 178.

my code seems to have a distinct count per month but does not exclude any values counted in prior months.. what is wrong with my approach here?

VAR CurrentMonthOrder = selectedvalue('Supported Business'[RR SUP BUS MONTH ORDER])


VAR PreviousMonths =
calculatetable(
 values('Supported Business'[Exporter Name]),

'Supported Business'[RR_SUPPORTED_FY]="2023-2024" &&
'Supported Business'[RR SUP BUS MONTH ORDER] < CurrentMonthOrder
 )



VAR ExportersThisMonth =
calculatetable(
 values('Supported Business'[Exporter Name]),
  'Supported Business'[RR_SUPPORTED_FY]="2023-2024"
    && 'Supported Business'[RR SUP BUS MONTH ORDER] = CurrentMonthOrder
 )

/*
VAR UniqueExportersThisMonth = EXCEPT(
    ExportersThisMonth,
    PreviousMonths
)
*/

var test =
calculate(DISTINCTCOUNT('Supported Business'[Exporter Name]),
'Supported Business'[RR_SUPPORTED_FY]="2023-2024",
not('Supported Business'[Exporter Name]) in PreviousMonths
)

RETURN

test
3 REPLIES 3
sparamanga
New Member

I actually started with the comma syntax.. but as the measure didnt return what i was expecting i tried the && syntax.. ill revert oit back to comma again.. do you think this will now return the correct result?

no, it propably doesn't mattre that much.
Can't tell from what you've posted why it is not working. Are there other tables involved with an active relationship? for instance a date table? Or are you creating a computed column instead of a measure?

sjoerdvn
Super User
Super User

start by replacing the "&&" with commas in the calculatetable statements.

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.