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! Request now

Reply
Anonymous
Not applicable

Distinct Count not working when selected all months

Hello

 

I am working on headcount data and looking for distinct Emp ID each month and accordingly year

 

Distinct count is working when i select single month , however when all months are selected (yearly unique employees active) the total number is coming correct but drill down metrics like gender and others are incorrect values.

 

Distinct count is arrived from selection of _hc=1 (1 is active employee and 0 is exit employee) and _ID - disctinct count i am doing

 

 

 

PBX is attached.I did comparison and values coming incorrectI did comparison and values coming incorrect

 

 

 

 

 

 

Regards

 

4 REPLIES 4
Anonymous
Not applicable

Hi  @Anonymous ,

Here are the steps you can follow:

1. Create measure.

discount_id =
var _select=SELECTCOLUMNS('Sheet1',"1",'Sheet1'[Fiscal Month])
return
CALCULATE(DISTINCTCOUNT('Sheet1'[_id]),FILTER(ALL(Sheet1),'Sheet1'[Fiscal Month] in _select&&'Sheet1'[_job family]=MAX('Sheet1'[_job family])))
discount_id_total =
var _table=SUMMARIZE('Sheet1','Sheet1'[_job family],"_value",[discount_id])
return
IF(HASONEVALUE('Sheet1'[_job family]),[discount_id],SUMX(_table,[_value]))

2. Result:

vyangliumsft_0-1644887769859.jpeg

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Anonymous
Not applicable

thanks Liu..however the no is not matching total distinct count will be 1081Logic used , _hc =1 , removed duplicated _id and got this number as overall active on fiscal yearLogic used , _hc =1 , removed duplicated _id and got this number as overall active on fiscal year

Also i need to show at gender level , org level etc .. the measure shared is not working as its linked with job family

amitchandak
Super User
Super User

@Anonymous , distinctcount is recalculated in grand total again. so it distinctcount  year not sum of month values

 

if you want sum of month value

then

sumx(values(Date[Month Year]), calculate(distinctcount(Table[emp id]) ) )

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

this is not working for me , the single month selection is correct but all months when selected - value coming incorrect

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