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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
doubleclick
Resolver I
Resolver I

Change from Countx to DistinctCount

Hi All,

 

I have a cool formula here but i'm having trouble converting it to a distinct count 

I want to change the below into a distinctcount of a column called [Worker] - how can i change this?

 

Tenure by Day (Count over 365 days) = 
VAR SoM=min('Calendar'[Date])
VAR EoM=max('Calendar'[Date])
RETURN countx(CALCULATETABLE(MainTable,All('Calendar'),filter(MainTable,(DATEDIFF(MainTable[Start Date],EoM,DAY)>=365)),MainTable[Start Date]<=EoM,ABS(
MainTable[End Date]>=SoM)),DATEDIFF(MainTableDE[Start Date],EoM,DAY))

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@doubleclick , Try like

 


calculate( distinctcount(MainTableDE[Worker]) ,All('Calendar'),filter( MainTable,(DATEDIFF(MainTable[Start Date],EoM,DAY)>=365)),MainTable[Start Date]<=EoM,ABS(
MainTable[End Date]>=SoM))

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

View solution in original post

3 REPLIES 3
gotohbh
Frequent Visitor

Hello,

 

i want transformed countx to distinctcount in this formule :

Count lots Months 2 = VAR __Table = GROUPBY('dw V_F_ObjetQuittanceSinistre','dw V_F_ObjetQuittanceSinistre'[DateReference_AnneeMois],"__Count",COUNTX (CURRENTGROUP(),[Lots]))
RETURN
    MAXX(__Table,[__Count])
amitchandak
Super User
Super User

@doubleclick , Try like

 


calculate( distinctcount(MainTableDE[Worker]) ,All('Calendar'),filter( MainTable,(DATEDIFF(MainTable[Start Date],EoM,DAY)>=365)),MainTable[Start Date]<=EoM,ABS(
MainTable[End Date]>=SoM))

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

Thank you so much!!!! This fixed it - Issue Resolved!

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.