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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
fbostan1
Helper I
Helper I

DAX Formula

Hi, 

I need help to figure how to subtract line 1 from lline 2 and so on..

is this needs to be done in a DAX formula or is there another way that can be done?

fbostan1_0-1750361382263.png

 

 

thanks

2 ACCEPTED SOLUTIONS

I hope I correctly understood what you are achieving. Here is a new measure

Row Difference = 
VAR CurrentCountry = SELECTEDVALUE('Securities Cash Flow'[County])
VAR CurrentMonth = SELECTEDVALUE('Securities Cash Flow'[Month Name])
VAR CurrentYear = SELECTEDVALUE('Securities Cash Flow'[New Biz Year])
VAR CurrentAVCount = SELECTEDVALUE('Securities Cash Flow'[AY_Count])
VAR CurrentValue = SELECTEDVALUE('Securities Cash Flow'[Mutual Funds])

VAR PreviousValue = 
    CALCULATE(
        SELECTEDVALUE('Securities Cash Flow'[Mutual Funds]),
        FILTER(
            ALL('Securities Cash Flow'),
            'Securities Cash Flow'[County] = CurrentCountry &&
            'Securities Cash Flow'[Month Name] = CurrentMonth &&
            'Securities Cash Flow'[New Biz Year] = CurrentYear &&
            'Securities Cash Flow'[AY_Count] = CurrentAVCount - 1
        )
    )

RETURN
    IF(
        NOT ISBLANK(CurrentValue) && NOT ISBLANK(PreviousValue),
        CurrentValue - PreviousValue,
        BLANK()
    )

 

Elena_Kalina_0-1750431470226.pngElena_Kalina_1-1750431500605.png

 

View solution in original post

Try this one

Year to Year Difference = 
VAR CurrentCountry = SELECTEDVALUE('Securities Cash Flow'[County])
VAR CurrentMonth = SELECTEDVALUE('Securities Cash Flow'[Month Name])
VAR CurrentYear = SELECTEDVALUE('Securities Cash Flow'[New Biz Year])
VAR CurrentAVCount = SELECTEDVALUE('Securities Cash Flow'[AY_Count])
VAR CurrentValue = SELECTEDVALUE('Securities Cash Flow'[Mutual Funds])

VAR PreviousYearValue = 
    CALCULATE(
        SELECTEDVALUE('Securities Cash Flow'[Mutual Funds]),
        FILTER(
            ALL('Securities Cash Flow'),
            'Securities Cash Flow'[County] = CurrentCountry &&
            'Securities Cash Flow'[Month Name] = CurrentMonth &&
            'Securities Cash Flow'[New Biz Year] = CurrentYear - 1 &&
            'Securities Cash Flow'[AY_Count] = CurrentAVCount
        )
    )

RETURN
    IF(
        NOT ISBLANK(CurrentValue) && NOT ISBLANK(PreviousYearValue),
        CurrentValue - PreviousYearValue,
        BLANK()
    )

View solution in original post

7 REPLIES 7
fbostan1
Helper I
Helper I

Hi @Elena_Kalina ,

 

I am expending this dashboard. Would it be possible to tweek this Dax to get me a year to year difference on a new table OR I need a different Dax formula?

Try this one

Year to Year Difference = 
VAR CurrentCountry = SELECTEDVALUE('Securities Cash Flow'[County])
VAR CurrentMonth = SELECTEDVALUE('Securities Cash Flow'[Month Name])
VAR CurrentYear = SELECTEDVALUE('Securities Cash Flow'[New Biz Year])
VAR CurrentAVCount = SELECTEDVALUE('Securities Cash Flow'[AY_Count])
VAR CurrentValue = SELECTEDVALUE('Securities Cash Flow'[Mutual Funds])

VAR PreviousYearValue = 
    CALCULATE(
        SELECTEDVALUE('Securities Cash Flow'[Mutual Funds]),
        FILTER(
            ALL('Securities Cash Flow'),
            'Securities Cash Flow'[County] = CurrentCountry &&
            'Securities Cash Flow'[Month Name] = CurrentMonth &&
            'Securities Cash Flow'[New Biz Year] = CurrentYear - 1 &&
            'Securities Cash Flow'[AY_Count] = CurrentAVCount
        )
    )

RETURN
    IF(
        NOT ISBLANK(CurrentValue) && NOT ISBLANK(PreviousYearValue),
        CurrentValue - PreviousYearValue,
        BLANK()
    )
fbostan1
Helper I
Helper I

@Elena_Kalina Thank you so much, this one worked perfectly fine! Kudos to you!!

Jihwan_Kim
Super User
Super User

Hi,

One of ways is using visual calculation.
Please check the below picture and the attached pbix file, and I tried to create a sample pbix file like below.

 

Using visual calculations in Power BI Desktop - Power BI | Microsoft Learn

 

 

Jihwan_Kim_0-1750380126978.png

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
Elena_Kalina
Solution Sage
Solution Sage

Hi @fbostan1 

Please try to use this measure

Row Difference = 
VAR CurrentRowValue = SELECTEDVALUE('Securities Cash Flow'[Mutual Funds], BLANK())
VAR CurrentIndex = SELECTEDVALUE('Securities Cash Flow'[AY_COUNT])
VAR PreviousRowValue = 
    LOOKUPVALUE(
        'Securities Cash Flow'[Mutual Funds],
        'Securities Cash Flow'[AY_COUNT], CurrentIndex - 1,
        'Securities Cash Flow'[Month Name], SELECTEDVALUE('Securities Cash Flow'[Month Name])
    )
RETURN
    IF(
        NOT ISBLANK(CurrentRowValue) && NOT ISBLANK(PreviousRowValue),
        CurrentRowValue - PreviousRowValue,
        BLANK()
    )

Elena_Kalina_1-1750363766361.png

 

If this post helps, then please consider Accepting as solution to help the other members find it more quickly, don't forget to give a "Kudos" – I’d truly appreciate it! 

Thank you.

 

this formula not working for me, 

sorry I forgot to mention that those numbers was added from US anc CAN to get North America. 

fbostan1_0-1750429079023.pngfbostan1_1-1750429164919.png

 

I hope I correctly understood what you are achieving. Here is a new measure

Row Difference = 
VAR CurrentCountry = SELECTEDVALUE('Securities Cash Flow'[County])
VAR CurrentMonth = SELECTEDVALUE('Securities Cash Flow'[Month Name])
VAR CurrentYear = SELECTEDVALUE('Securities Cash Flow'[New Biz Year])
VAR CurrentAVCount = SELECTEDVALUE('Securities Cash Flow'[AY_Count])
VAR CurrentValue = SELECTEDVALUE('Securities Cash Flow'[Mutual Funds])

VAR PreviousValue = 
    CALCULATE(
        SELECTEDVALUE('Securities Cash Flow'[Mutual Funds]),
        FILTER(
            ALL('Securities Cash Flow'),
            'Securities Cash Flow'[County] = CurrentCountry &&
            'Securities Cash Flow'[Month Name] = CurrentMonth &&
            'Securities Cash Flow'[New Biz Year] = CurrentYear &&
            'Securities Cash Flow'[AY_Count] = CurrentAVCount - 1
        )
    )

RETURN
    IF(
        NOT ISBLANK(CurrentValue) && NOT ISBLANK(PreviousValue),
        CurrentValue - PreviousValue,
        BLANK()
    )

 

Elena_Kalina_0-1750431470226.pngElena_Kalina_1-1750431500605.png

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.

Top Solution Authors