Fustavo Gringe
Fustavo Gringe

Reputation: 37

Price change Tracker

I have problem where my power bi data is sourced from sql where we have product with price but price will change of the product at future dates . now how would i create a DAX query which will help me in viualize the profit and track of price change

sample data: enter image description here

Upvotes: 0

Views: 159

Answers (1)

Strictly Funk
Strictly Funk

Reputation: 358

Here's an option using DAX measures that will allow you to show the price change monthly, quarterly, or annually:

average price = AVERAGE(Table[Price])

% Price Change = IF(NOT(ISBLANK([average price])),
VAR CurrentValue = [average price]
VAR PreviousValue = 
SWITCH(
    TRUE(),
    ISINSCOPE(Table[Date].[Month]), CALCULATE([average price], PARALLELPERIOD(Table[Date],-1,MONTH)),
    ISINSCOPE(Table[Date].[Quarter]), CALCULATE([average price], PARALLELPERIOD(Table[Date],-1,QUARTER)),
    ISINSCOPE(Table[Date].[Year]), CALCULATE([average price], PARALLELPERIOD(Table[Date],-1,YEAR))
)
RETURN
DIVIDE(
    CurrentValue - PreviousValue,
    PreviousValue
))

Upvotes: 1

Related Questions