Data_Analyst
Data_Analyst

Reputation: 81

Would like to do a previousquarter calculation but for the first quarter show the value without the calculation

I have dax written that returns the sales by subtracting the sales ytd by sales ytd in the previous quarter, this is to show on a pie chart or donut chart. I would like some help as I would also like to show the first quarter without the calculation.

My current dax is shown below:

Measure = 
VAR RESULT = CALCULATE(
    [Sale YTD],
    PREVIOUSQUARTER(dimSalesDate[DATE])
)

RETURN [Sale YTD] - RESULT

my data:

quarter no        sales ytd

1                 50,000
2                 70,000
3                 150,000
4                 280,000

what I want to show in a pie/donut chart

quarter no           sales ytd

1                    50,000  (no calculation)
2                    20,000  (calculation: 70,000 - 20,000)
3                    80,000  (calculation: 150,000 - 70,000)
4                    130,000 (calculation: 280,000 - 150,000)

Upvotes: 1

Views: 202

Answers (1)

Mark Wojciechowicz
Mark Wojciechowicz

Reputation: 4477

I think you may be looking for something like this:

Sales YTD Less Prior Quarter =
VAR RESULT =
    IF (
        SELECTEDVALUE(dimSalesDate[Quarter]) = 1,
        [Sale YTD],
        [Sale YTD] - CALCULATE ( [Sale YTD], PREVIOUSQUARTER ( dimSalesDate[DATE] ) )
    )
RETURN
    RESULT

Upvotes: 1

Related Questions