Forum Discussion

Aj_BI's avatar
Aj_BI
Frequent Visitor
6 years ago
Solved

DAX Query to Find Next Value

Hi All, I am new in PowerBI and need your help! I have a table like below having the Date Time Stamp as first column with Sales in second column. What I need is a formula to compute a third column(...
  • Icey's avatar
    6 years ago

    Hi Aj_BI ,

    Try this:

    Rank =
    RANKX (
        ALL ( TableTest ),
        CALCULATE ( MAX ( TableTest[Date_Time] ) ),
        ,
        ASC,
        DENSE
    )
    Sales-1 =
    VAR index = [Rank] - 1
    RETURN
        CALCULATE (
            SUM ( TableTest[Sales] ),
            FILTER ( ALL ( TableTest ), index = [Rank] )
        )
    Sales-2 =
    VAR index = [Rank] - 2
    RETURN
        CALCULATE (
            SUM ( TableTest[Sales] ),
            FILTER ( ALL ( TableTest ), index = [Rank] )
        )

     

     

    Best Regards,
    Icey

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.