Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago

Selecting only the latest date between many using DAX

Hello everyone,

 

Happy new year ! ðŸŽ‰

 

It's my first time asking a question here, but I am cornered, hope one of you will be able to help me !

 

Here is the situation : I want to create a matrix using an extraction from my HR tool. The use is to follow if my employees have had their interview with their managers every 2 years (after the hiring).

 

The extraction gives me all the interviews of the employees but I only want to use the latest.

 

I created a new metric to filter the table using this DAX expression :

__________
Date_la_plus_recente=

VAR date_recente =

MAX('Entretien professionnel 2022'[Date d'entretien])

RETURN

CALCULATE(

    date_recente,

    FILTER(

        ALL ('Entretien professionnel 2022'),

        CALCULATE(COUNT('Entretien professionnel 2022'[Nom d'utilisateur]),'Entretien professionnel 2022'[Nom d'utilisateur] = EARLIER('Entretien professionnel 2022'[Nom d'utilisateur])

        && 'Entretien professionnel 2022'[Date d'entretien]=date_recente

        )

    ))
__________________
It works, now I only see one line for each employee (when Not OK) BUT (and here is my problem), I also want to calculate the penalty tax if the interview hasn't been done on time (NOK).
 
The maximum tax is 3000€/employee, as you can see PBI made the sum of every line for every employee and the total is also
the same as before (so it's wrong).


I thought that I can modify it by selecting "don't resume" on the visualisation pannel :

 but this earase the "Total" line and I need it.

 
Power BI calculates the sum of every line of the table even if it doesn't show on my graphs. I wanted to add a new column to add a filter by "True or False" like that : 

=IF([Date d'entretien]=date_recente,TRUE,FALSE) 
But it dont work as well...
 

Do you have any idea of what I can do ? 

 

Thank you in advance !

2 Replies