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

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

Reply
amansinghfirstb
Helper III
Helper III

Problem in getting % change values

This has been one harrowing tale where so far I have tried every trick in the book to get the answer but nothing has worked so far.  I want something like column F( which uses created column G). The highlighted cells are given and I need column F through DAX.

column F calculates the % order change in the current week wrt the average order for the previous weeks. As you can see

 

 

15 REPLIES 15
DataInsights
Super User
Super User

@amansinghfirstb,

 

Try these measures:

 

Total Qty = SUM ( Orders[Qty] )

% Change = 
VAR vShipWk =
    MAX ( Orders[Schedule Ship Wk] )
VAR vDistinctShipWk =
    ALL ( Orders[Schedule Ship Wk] )
VAR vPrevShipWk =
    FILTER ( vDistinctShipWk, Orders[Schedule Ship Wk] < vShipWk )
VAR vPrevShipWkQty =
    ADDCOLUMNS ( vPrevShipWk, "TotalQty", [Total Qty] )
VAR vAverage =
    AVERAGEX ( vPrevShipWkQty, [TotalQty] )
VAR vResult =
    DIVIDE ( [Total Qty] - vAverage, vAverage )
RETURN
    vResult

 

DataInsights_0-1603561973545.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




This is not coming out right.

amansinghfirstb_0-1603733592681.pngamansinghfirstb_1-1603733655188.png

 

@amansinghfirstb,

 

Line 9 should use [Total Qty].

 

Line 11 should use [TotalQty] (no space).

 

It's best practice not to precede measures with a table name.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Thanks, I did the correction, but why am i getting the total like this?

 

Capture23.PNG

 
 
 

Order Fluctuation% change as 108.81% doesn't make sense. Can I remove it?

 

 

@amansinghfirstb,

 

Replace the last line of the measure with this so it will display blank for the total row:

 

IF ( HASONEVALUE ( Orders[Schedule Ship Wk] ), vResult, BLANK() )

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




@DataInsights 

I noticed something off here. When I put Business column back in the table the order fluctuation goes for a toss. 

amansinghfirstb_0-1603740371440.pngamansinghfirstb_1-1603740400150.png

Ideally, all the businesses with common week number should have same order fluctuation % as it is being calculated wrt to the total of the week.

 

@amansinghfirstb,

 

Would you be able to provide the expected result and how it is calculated? You can paste the table visual into Excel and create formulas that show the calculation logic.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Business UnitOrdered ItemQtyQty FulfilledSchedule Ship Wk% change
ASCWP-9938393910
FRAMBWP2118SP29829810
FRAMBWP2157BR343410
ASCWP-3731981982941%
ASCWP-490HD32322941%
ASCWP-59240402941%
ASCWP-6016016012941%
ASCWP-6574114112941%
ASCWP-715HD3283282941%
ASCWP-7758598592941%
ASCWP-8534164162941%
ASCWP-910090902941%
ASCWP-92407047042941%
ASCWP-982922222941%
ASCWP-986144442941%
ASCWP-HD630198982941%
FRAMBWP2056BR112941%
FRAMBWP2056GP442941%
FRAMBWP2095GP332941%
FRAMBWP2115BR222941%
FRAMBWP2195BR222941%
FRAMBWP2422BR662941%
ASCWP-110675753282%
ASCWP-19834064063282%
ASCWP-20671071073282%
ASCWP-209335353282%
ASCWP-22212672673282%
ASCWP-22714064063282%
ASCWP-23781541543282%
ASCWP-24686006003282%
ASCWP-26841171173282%
ASCWP-366HDA84843282%
ASCWP-373HDP18183282%
ASCWP-413HDA663282%
ASCWP-5951401403282%
ASCWP-6451891893282%
ASCWP-6611401403282%
ASCWP-7266606603282%
ASCWP-8361601603282%
ASCWP-8533363363282%
ASCWP-88894943282%
ASCWP-90464504503282%
ASCWP-91641721723282%
ASCWP-92254374373282%
ASCWP-9361132013203282%
ASCWP-94082162163282%
ASCWP-94144904903282%
ASCWP-983972723282%
ASCWP-9860-EA4024023282%
ASCWP-993340403282%
ASCWP-9939553282%
ASCWP-HD60731401403282%
ASCWP-TM27K610527273282%
CarterM60318B-01011881883282%
FRAMBWP2556BR993282%
FRAMBWP511SP223282%
FRAMBWP9240DG43433282%
FRAMWP462 SP20203282%
FRAMWP635 BLANCA113282%
FRAMWP635 SP55553282%

 

% change =abs( sum of order quantitiy for a particular week- average of order quantity for all previous weeks)/average of order quantity for all previous weeks

 

Your code works well for outer filters, but when I add fields inside the table it starts giving weird results. I have 15 more fields that I want users to slice/dice the data on. This % change data will only depend on the week selected.

@amansinghfirstb,

 

I get the same % change as you show (941% and 282%), with Business Unit displayed, as well as Business Unit not displayed. Would you post the % change measure so I can see your DAX?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




amansinghfirstb_0-1603821335985.png

 

 

amansinghfirstb_1-1603821361877.png

 

I am pulling Total Qty1 from this measure I defined.

amansinghfirstb_2-1603821391121.png

 

@amansinghfirstb,

 

Line 11 of your measure is wrong.

 

Line 11 should use [TotalQty] (no space). This is a temporary column that is created for calculation purposes.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Total Qty = SUM ( Orders[Qty] )

@DataInsights Did you mean this?

How would you put this in the same measure of order % fluctuation?

@amansinghfirstb,

 

Try this measure. I rewrote it using your table/column names, and modified the logic to handle different granularities.

 

Order Fluctuation % change = 
VAR vShipWk =
    MAX ( 'All Fill Rate'[Wk] )
VAR vDistinctShipWk =
    ALLSELECTED ( 'All Fill Rate'[Wk] )
VAR vTotalQty =
    CALCULATE (
        SUM ( 'All Fill Rate'[Qty] ),
        ALLEXCEPT ( 'All Fill Rate', 'All Fill Rate'[Wk] )
    )
VAR vPrevShipWk =
    FILTER ( vDistinctShipWk, 'All Fill Rate'[Wk] < vShipWk )
VAR vPrevShipWkQty =
    ADDCOLUMNS (
        vPrevShipWk,
        "tmpTotalQty",
            CALCULATE (
                SUM ( 'All Fill Rate'[Qty] ),
                ALLEXCEPT ( 'All Fill Rate', 'All Fill Rate'[Wk] )
            )
    )
VAR vAverage =
    AVERAGEX ( vPrevShipWkQty, [tmpTotalQty] )
VAR vResult =
    DIVIDE ( vTotalQty - vAverage, vAverage )
RETURN
    IF ( HASONEVALUE ( 'All Fill Rate'[Wk] ), vResult, BLANK () )

 

DataInsights_0-1603837180155.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




amansinghfirstb_0-1603839683430.png

 

amansinghfirstb_1-1603839704099.png

Still no success. Infact, even the aggregate values without internal filters are coming out wrong.

Also, why did you initialize the total qty with sum for all qty except the selected week? (Line 7,8) Doesn't make sense. 

amansinghfirstb_2-1603839735780.png

 

@amansinghfirstb,

 

The variable vTotalQty (lines 6-9) uses ALLEXCEPT in order to remove the filter criteria from all columns except [Wk]. You need to keep the [Wk] filter (from the current row), but ignore filters from Business Unit, and any other columns you add to the visual.

 

If you could upload a sanitized version of your pbix, I'll take a look.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

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

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.