Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
firstch
Helper III
Helper III

Please help how to write dax for this situation

Hi all please help me with dax for this problem ,I want to show previous year price with this data

yearregionstateprice
2019midDC                900.00
2019centerNY                900.00
2019eastLA                900.00
2020midDC                920.00
2020centerNY                920.00
2020eastLA                920.00
2021midDC                950.00
2021centerNY                950.00
2021eastLA                950.00

I want to display this in correct way

firstch_1-1657282583060.png

 

firstch_0-1657282424993.png

I want to display on card with percent different  of previous year 
thankyou in advance
Best Regard 
firstch



1 ACCEPTED SOLUTION
v-easonf-msft
Community Support
Community Support

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)

veasonfmsft_0-1657698390228.png

 

Best Regards,
Community Support Team _ Eason

 

View solution in original post

4 REPLIES 4
v-easonf-msft
Community Support
Community Support

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)

veasonfmsft_0-1657698390228.png

 

Best Regards,
Community Support Team _ Eason

 

Its works thanks so much ,and terribly sorry for veryvery late reply
Best Regard 
firstch

Anonymous
Not applicable

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

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.