Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago

Create a measure to calculate a value difference between the latest and the earliest date

I want to create a measure to find the sum of the below between the latest date and the earliest date. 
I have a column for the date in the table

measure= qty * price

1 Reply

  • Hello Anonymous,

     

    You can use the following DAX formula:

    TotalAmount =
    CALCULATE(
        SUMX(
            TableName,
            TableName[qty] * TableName[price]
        ),
        FILTER(
            TableName,
            TableName[date] = MAX(TableName[date])
                || TableName[date] = MIN(TableName[date])
        )
    )

    Should you require further details or assistance please do not hesitate to reach out to me.