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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
doubleclick
Helper II
Helper II

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

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

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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors