Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

DATEDIFF - Dates not selectable in the Measure.

I want to calculate the days difference between two dates, So I started a DATDIFF Expression but I cannot get the Two Dates shwoing as a selection.

 

The Dates are named as so.

Any idea why they are not showing automatically? Is it because its a Date and not date & time.

 

  • Your measure needs to know which tables to find the columns in and you need to tell it what aggregation context to use. You could try something like:

     

    Difference =
    VAR ConfirmedD = SELECTEDVALUE('Table Name'[Confirmed Date])

    VAR CompletedD = SELECTEDVALUE('Table Name'[Completed Date])

    RETURN

    DATEDIFF(ConfirmedD,CompletedD,DAY)

     

     

2 Replies

  • halfglassdarkly's avatar
    halfglassdarkly
    Responsive Resident

    Your measure needs to know which tables to find the columns in and you need to tell it what aggregation context to use. You could try something like:

     

    Difference =
    VAR ConfirmedD = SELECTEDVALUE('Table Name'[Confirmed Date])

    VAR CompletedD = SELECTEDVALUE('Table Name'[Completed Date])

    RETURN

    DATEDIFF(ConfirmedD,CompletedD,DAY)