Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Running difference

This is a running difference problem.  I tried to take the learnings I saw in another post but was unsuccessful. What I want to get to is this rough presentation below.  I have two questions: 1. Ho...
  • Anonymous's avatar
    Anonymous
    7 years ago

    Please ignore my previous post from a few minutes ago.   I found a data error so just for the people who are reading this post in the future, this DAX code did indeed work BUT!!! only when I added the RowType field to the previous suggested change. The successful DAX code now looks like this for the RunDiff column:

    RunDiff =
    Tax[Value]
        - LOOKUPVALUE (
            Tax[Value],
            Tax[Person], Tax[Person],
            Tax[Report Category], Tax[Report Category],
            Tax[RowType],Tax[RowType],
            Tax[Description], Tax[Description],
            Tax[Tax Year], Tax[Tax Year],
            Tax[Period], CALCULATE (
                MAX ( Tax[Period] ),
                FILTER ( Tax, Tax[Period] < EARLIER ( Tax[Period] ) )
            )
        )
    If you fail to put in the RowType you will get the error message about too many values when a single value was expected.
     
    Note that the column value "First" in Tax.Period returns the value and not the difference.  Since there is no prior column, that is ok and the slicer just removes it from the presentation anyway.  Here is what it looks like in the end where the differences from the values are presented: