Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Substract any row value from the previous row values

Month Quarter Data point Sales Quantity Jan/18 1 1                  262 Feb/18 1 2                  732 Mar/18 1 3                    15 Apr/18 2 4                  958 ...
  • AlB's avatar
    5 years ago

    Hi Anonymous 

    You need to create an additional one-column table to use as slicer to select the base date. Otherwise, using the date column in your fact table would filter the values in the visual down to only the selected date. 

    1. Create that additional table with the date values from the date table:

    BaseDatesTable = DISTINCT(Table1[Month]) 

     or with others if you need a more complete/standard list. No relationships with the fact table

    2. Create this measure and place it in the visual:

    Difference = 
    VAR currentDataPoint_ =
        SELECTEDVALUE ( Table1[Data point] )
    VAR currentDate_ =
        SELECTEDVALUE ( Table1[Month] )
    VAR baseDate_ =
        SELECTEDVALUE ( BaseDatesTable[Month] )
    VAR baseDataPoint_ =
        CALCULATE (
            DISTINCT ( Table1[Data point] ),
            Table1[Month] = baseDate_,
            ALL ( Table1 )
        )
    RETURN
        baseDataPoint_ - currentDataPoint_

    3. See it all at work in the attached file

     

    Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

    Contact me privately for support with any larger-scale BI needs, tutoring, etc.

    Cheers