Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi all please help me with dax for this problem ,I want to show previous year price with this data
year | region | state | price |
2019 | mid | DC | 900.00 |
2019 | center | NY | 900.00 |
2019 | east | LA | 900.00 |
2020 | mid | DC | 920.00 |
2020 | center | NY | 920.00 |
2020 | east | LA | 920.00 |
2021 | mid | DC | 950.00 |
2021 | center | NY | 950.00 |
2021 | east | LA | 950.00 |
I want to display this in correct way
I want to display on card with percent different of previous year
thankyou in advance
Best Regard
firstch
Solved! Go to Solution.
Hi, @firstch
Try formula like:
from last year =
VAR Currenty =
SELECTEDVALUE ( 'Sheet1'[year] )
RETURN
CALCULATE (
average( 'Sheet1'[price] ),
'Sheet1'[year] = Currenty - 1,
ALLEXCEPT ( Sheet1, Sheet1[region], Sheet1[state] )
)
Current Price = IF(ISFILTERED(Sheet1[year]),AVERAGEX(Sheet1,Sheet1[price]),BLANK())
diff =
var a=[Current Price]-[from last year]
return IF(ISBLANK([from last year]),BLANK(),a)
Best Regards,
Community Support Team _ Eason
Hi, @firstch
Try formula like:
from last year =
VAR Currenty =
SELECTEDVALUE ( 'Sheet1'[year] )
RETURN
CALCULATE (
average( 'Sheet1'[price] ),
'Sheet1'[year] = Currenty - 1,
ALLEXCEPT ( Sheet1, Sheet1[region], Sheet1[state] )
)
Current Price = IF(ISFILTERED(Sheet1[year]),AVERAGEX(Sheet1,Sheet1[price]),BLANK())
diff =
var a=[Current Price]-[from last year]
return IF(ISBLANK([from last year]),BLANK(),a)
Best Regards,
Community Support Team _ Eason
Its works thanks so much ,and terribly sorry for veryvery late reply
Best Regard
firstch
You need to use time-intelligence functions. You can solve this with PREVIOUSYEAR(), SAMEPERIODLASTYEAR(), PARALLELPERIOD, DATEADD, DATESINPERIOD. Here's a video that might guide you (not from my authoring 🙂 ) https://www.youtube.com/watch?v=lGBVOTqYb88
hi@ Raymundo2910 will PREVIOUS YEAR WORK? cause i didnt have date dimension
Best Regard
firstch
User | Count |
---|---|
25 | |
12 | |
8 | |
7 | |
7 |
User | Count |
---|---|
25 | |
12 | |
11 | |
10 | |
6 |