Forum Discussion

Kris48's avatar
Kris48
Frequent Visitor
1 year ago
Solved

Assign a maximum value per index

When the 'Index' in the 'Fact' table has a 'data from' later than today's date, then take the last 'value' from the 'Rev' table assigned to that index and multiply this value by the number of days th...
  • shafiz_p's avatar
    1 year ago

    Hi Kris48  Considering you want to achieve, If data from is later than today's date , then take the last value from the rev table assigned to that index and multiply by dates between. Try revise your measure by the code below:

    Value_measure = 
    VAR CurrentDate = TODAY()
    VAR FilteredFact = 
        FILTER(
            'Fact',
            'Fact'[Data from] > CurrentDate
        )
    VAR LastRevValue = 
        CALCULATE(
            LASTNONBLANKVALUE('Rev'[Date], SUM('Rev'[Value])),
            TREATAS(VALUES('Fact'[INDEX]), 'Rev'[INDEX])
        )
    VAR DaysBetween = 
        SUMX(
            FilteredFact,
            DATEDIFF('Fact'[Data from], 'Fact'[Data to], DAY)+1
        )
    RETURN
        LastRevValue * DaysBetween

    Output I have :

     

     

    Hope this helps!!

    If this solved your problem, please accept it as a solution and kudos!!

     

    Best Regards,

    Shahariar Hafiz