Forum Discussion

afkl99's avatar
afkl99
Frequent Visitor
9 years ago
Solved

Dividing rows in table

Hi,  I am new to power bi and am trying to transfer my r code into steps in the power bi query The r code itterates through each row of the data frame and divides the value in row (a) by the value...
  • CahabaData's avatar
    9 years ago

    this may help get you on your path - it doesn't do the calculation but does bring in the value from the prior day/row:

    terms are generic - first is a calculated column approach:

     

    PreDaySessions_Column =

    VAR CurrentDay = Table1[Date]

    VAR PreDay =

     CALCULATE ( MAX ( Table1[Date] ), FILTER ( Table1, Table1[Date] < CurrentDay ) )

    RETURN

     LOOKUPVALUE ( Table1[SessionS], Table1[Date], PreDay )

     

    this is a Measure

    PreDaySessions_Measure =

    VAR PreDay =

      PREVIOUSDAY ( Table1[Date] )

    RETURN

     LOOKUPVALUE ( Table1[SessionS], Table1[Date], PreDay )