0
votes

I have a measure that calculates previous recorded sales now I would like to work out the difference between period sales against previous period sales, I tried simple subtraction but I get error message.. Any suggestions please.. Thanks

Sales Change:= sales[sales]-Previous Day Sales 
Previous Day Sales :=
CALCULATE (
    SUM ( Sales[Sales] ),
    FILTER (
        ALL ( Sales ),
        Sales[Date]
            = CALCULATE (
                MAX ( Sales[Date] ),
                FILTER (
                    ALL ( Sales ),
                    COUNTROWS ( FILTER ( Sales, EARLIER ( Sales[Date] ) < Sales[Date] ) )
                )
            )
    )
)
1
What is the error you are getting? What is the context where you want to calculate this measure?. Are you using [Previous Day Sales] (note the brackets around the measure name) in the Sales Change measure?alejandro zuleta
@alejandro zuleta, error :can not be determined in context , check for circular dependencies, occurs when a measure refer directly to a column without calculations have many values for each row, and not been specified. I have sales and calendar table both linked on column dates I am trying to create measure that compare sales on daily basis, I can use built in PREVIOUSDAY formula but it goes wrong on Mondays as no figures for Saturday and sundays. , yes I m using the measure := Sales[sales]-[Previous Day Sales].. RegardsMatrix1977

1 Answers

0
votes

If you are creating a measure you have to aggregate the Sales[Sales] using the SUM() function.

Sales Change := SUM(Sales[Sales])-[Previous Day Sales]

enter image description here

While creating measures you cannot refer to column values without an aggregation. Measures run in multiple contexts and the Sales[sales] column value cannot be calculated in a different context than the row context.