Forum Discussion

LeonardCs's avatar
LeonardCs
Helper I
1 year ago
Solved

HELP WITH DAX - DATE CALCULATION CONDITION

I have a calendar table and a table with all the employees of the company. In this employees table, there are details like employee ID, admission date, and dismissal date for those who have already b...
  • lbendlin's avatar
    1 year ago

    Your formulas can be simplified

    A_admissoes = COUNTROWS(TURNOVER)
    
    B_demissoes = CALCULATE(COUNTROWS(TURNOVER), USERELATIONSHIP(CALENDARIO[Date], TURNOVER[DATA_DEMISSÃO]))

     

    For the C measure you want to be very specific with your requirement. "Total active employees during the period "  is too fluffy. Better would be to say "Total number of employees who were active on at least one day of the period.

     

    C_ativosNoPeríodo = 
    var d = values(CALENDARIO[Date])
    var a = ADDCOLUMNS(all(TURNOVER),"Dem",COALESCE([DATA_DEMISSÃO],TODAY()))
    var b = ADDCOLUMNS(a,"i",COUNTROWS(INTERSECT(d,CALENDAR([DATA_ADMISSÃO],[Dem]))))
    return countrows(filter(b,[i]>0))