swad
swad

Reputation: 87

Date Difference on having condition on Dates (Power BI DAX)

I am trying to display number of days between two dates: I have two date columns (Joining_Date, Resigned_Date) in EMPtable and have created Independent Dimdate table and created slicer for Dimdate . Now i want to get datediff between [Joining_Date] and Dimdate from 'date slicer' having condition on Resigned_Date.

Below is the table Having Columns empid, joing_date, Resigned_date,

here Dimdate[date] is the selected date from filter.

I want to create measure DateDifference to calculate number of days between 'joining date' and 'dimdate' for empids whose 'Resigned_Date is greater than Dimdate or Resigned not present'.

enter image description here

can someone please help me to get this done?

Upvotes: 0

Views: 713

Answers (1)

Marcus
Marcus

Reputation: 4015

You can have a calculated column like so:

Date_Diff = 
IF (
    ISBLANK ( 'EMPtable'[Resigned_Date] ) , 
    DATEDIFF ( 
        'EMPtable'[Joining_Date], 
        TODAY () ,
        DAY
    )
) 

And another like so:

Status = 
IF ( 
    NOT ISBLANK ( 'EMPtable'[Resigned_Date] ) , 
    "Resigned" 
) 

However, in calculated columns you can't use a dynamic date, e.g. from a slicer selection. Calculated columns are computed only once at refresh time, not at query time.

Upvotes: 0

Related Questions