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! Request now

Reply
mbudiman
Helper III
Helper III

Calculate difference between versions of Forecast data

Hello,

 

I need help for a DAX measure to calculate Forecast Qty difference between versions for each Fiscal Qtr. A Fiscal Qtr may have multiple versions of Forecast. See example data below.

 

Fiscal QtrVersionVersion No (descending)Remark

FY26Q1

Oct-251Forecast for FY26Q1 as of Oct-25
FY26Q1Sep-25

2

Forecast for FY26Q1 as of Sep-25
FY26Q1Aug-253Forecast for FY26Q1 as of Aug-25

 

Here is the link for sample pbix data. I want to show Forecast Qty difference between versions as below. Pls advise. Thank you in advance. Forecast Difference from Prev.pbix

image.jpg

1 ACCEPTED SOLUTION
Ahmedx
Super User
Super User

and try this 

Measure = 
VAR NumQuarter = SELECTEDVALUE('Sales Forecast'[NumQuarter])-1
VAR PQTY = 
CALCULATE([FCST_QTY], 'Sales Forecast'[NumQuarter]= NumQuarter , REMOVEFILTERS('DimVersionNo'),REMOVEFILTERS(DimFYFISCAL))
RETURN
 [FCST_QTY] - PQTY 

Screenshot_1.pngScreenshot_4.png

View solution in original post

30 REPLIES 30
Ahmedx
Super User
Super User

try pls

Measure = 
VAR NumQuarter = SELECTEDVALUE('Sales Forecast'[NumQuarter])-1
VAR PQTY = 
CALCULATE([FCST_QTY], 'Sales Forecast'[NumQuarter]= NumQuarter , REMOVEFILTERS()
, SUMMARIZE('Sales Forecast','Sales Forecast'[SALES_REGION],'Sales Forecast'[SALES_COUNTRY],'Sales Forecast'[SALES_CHANNEL],'Sales Forecast'[PBU],'Sales Forecast'[SUB_MAIN_CAT_CODE],'Sales Forecast'[Part No])) 
RETURN
 [FCST_QTY] - PQTY

Screenshot_1.pngScreenshot_2.png

Ahmedx
Super User
Super User

I advise you to create a primary key to get the correct amount and to avoid it, so called "autexis"

kushanNa
Super User
Super User

Hi @mbudiman 

 

Please check if this is the output that you are looking for ? 

 

kushanNa_0-1759826980900.png

I have attached the pbix file with the dax for your reference 

 

hi @kushanNa ,

 

Thank you for suggesting a solution. However, the dax you provided is fixed to Version 2 - Version 1. It works if there are only 2 version. As mentioned, each Fiscal Qtr have multiple versions (more than 2 versions, up to users to generate as many version as applicable).

@mbudiman oh okay , please check if this dax works , this is a dynamic version one

 

FCST Qty Diff Dynamic = 
VAR MaxVersion =
    CALCULATE(
        MAX('Forecast'[Version No]),
        ALLEXCEPT(
            'Forecast',
            'Forecast'[SALES_CHANNEL],
            'Forecast'[SALES_REGION],
            'Forecast'[SALES_COUNTRY],
            'Forecast'[PBU],
            'Forecast'[PRODUCT_RANGE],
            'Forecast'[SUB_MAIN_CAT_CODE],
            'Forecast'[Part No],
            'Forecast'[FY_FISCAL_QTR]
        )
    )

VAR PrevVersion =
    CALCULATE(
        MAX('Forecast'[Version No]),
        ALLEXCEPT(
            'Forecast',
            'Forecast'[SALES_CHANNEL],
            'Forecast'[SALES_REGION],
            'Forecast'[SALES_COUNTRY],
            'Forecast'[PBU],
            'Forecast'[PRODUCT_RANGE],
            'Forecast'[SUB_MAIN_CAT_CODE],
            'Forecast'[Part No],
            'Forecast'[FY_FISCAL_QTR]
        ),
        'Forecast'[Version No] < MaxVersion
    )

VAR MaxQty =
    CALCULATE(
        SUM('Forecast'[FCST Qty]),
        'Forecast'[Version No] = MaxVersion
    )

VAR PrevQty =
    CALCULATE(
        SUM('Forecast'[FCST Qty]),
        'Forecast'[Version No] = PrevVersion
    )

RETURN
MaxQty - PrevQty

 

hi @kushanNa ,

 

Thanks again for the revised DAX. It does not work correctly when I add records for version 3.

mbudiman
Helper III
Helper III

hi @grazitti_sapna ,

 

I tried the DAX you provided. It does not work. Here is the pbix with DAX provided by you. Forecast Difference - solution from Sapna.pbix

Hi @mbudiman,

 

Please find the solution in attached .pbix file

Hi @Ahmedx,

 

Did it work for you?

grazitti_sapna
Super User
Super User

Hi @mbudiman,

 

You can achieve it by first clculating previous version forecast

 

PrevVersionForecast =
VAR CurrentFiscal = MAX('Forecast'[Fiscal Qtr])
VAR CurrentVersionNo = MAX('Forecast'[Version No])
RETURN
CALCULATE(
MAX('Forecast'[Forecast Qty]),
FILTER(
ALL('Forecast'),
'Forecast'[Fiscal Qtr] = CurrentFiscal &&
'Forecast'[Version No] = CurrentVersionNo + 1
)
)

Then calculating the difference between them

 

ForecastDifference =
VAR CurrentForecast = MAX('Forecast'[Forecast Qty])
VAR PreviousForecast = [PrevVersionForecast]
RETURN
IF(
NOT ISBLANK(PreviousForecast),
CurrentForecast - PreviousForecast,
BLANK()
)

 

🌟 I hope this solution helps you unlock your Power BI potential! If you found it helpful, click 'Mark as Solution' to guide others toward the answers they need.
💡 Love the effort? Drop the kudos! Your appreciation fuels community spirit and innovation.
🎖 As a proud SuperUser and Microsoft Partner, we’re here to empower your data journey and the Power BI Community at large.
🔗 Curious to explore more? [Discover here].
Let’s keep building smarter solutions together!

 

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