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
Truelearner
Helper III
Helper III

need help with DAX

I have employee hire dates i want to create the Total Employee column  @mgwena @cham @amitchandak @Greg_Deckler @Mariusz 

 

Employee Hire date NameDESIGNATIONEMPIDTotal Employee 
01-mar-2020RajCEO11
01-mar-2020RajCFO11
06-mar-2020RaviANALYST22
08-mar-2020KrishSENIOR33
08-mar-2020TriniBA44
12-Apr-2020ShafiTECHLEAD55

 

1 ACCEPTED SOLUTION

HI @Truelearner,

I'd like to suggest you add distinct function to remove duplicate rows:

Measure =
COUNTROWS (
    FILTER (
        DISTINCT ( ALLSELECTED ( Table ) ),
        [Hire Date] <= MAX ( Table[Hire Date] )
    )
)

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

5 REPLIES 5
v-shex-msft
Community Support
Community Support

HI @Truelearner,

If you want total employee count can interact with filters, I'd like to suggest you write a measure formula instead. (calculated column formula not able to interact with filter/slicers)

Measure =
COUNTROWS (
    FILTER ( ALLSELECTED ( Table ), [Hire Date] <= MAX ( Table[Hire Date] ) )
)

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

it works like a charm but with the data i have above it is counting the duplicate rows as well , is there any chance where i can ignore the duplicates like in my case same guy is CEO and CFO but i want to caluclate him as one single record though he has two recrods because of the designation

HI @Truelearner,

I'd like to suggest you add distinct function to remove duplicate rows:

Measure =
COUNTROWS (
    FILTER (
        DISTINCT ( ALLSELECTED ( Table ) ),
        [Hire Date] <= MAX ( Table[Hire Date] )
    )
)

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
Greg_Deckler
Super User
Super User

COUNTROWS(FILTER('Table',[Employee Hire Date] <= EARLIER([Employee Hire Date])))


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

its almost what i needed but the problem is with duplicates with DATA , can you check my table i posted about once.

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.