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
yaya1974
Helper III
Helper III

Formula Help

I am trying to subtract same column but different row, or previous period.  Everything I have tried keeps giving me the same value as in original column.   Here is screen shot of the output I am looking for in the adjument column.

Screenshot 2024-06-26 103703.png

 

Grateful for any help!

Thank you

Version: 2.131.901.0 64-bit

11 REPLIES 11
Ashish_Mathur
Super User
Super User

Hi,

Share the download link of the Excel file with your formulas already written there.  I will try to convert them into DAX formulas/measures. 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

I don't have in excel the screen shot below is of powerbi.  I can copy the code in:

 

Navistar Steel Adj =
VAR PreviousDate_ =
    CALCULATE(
        MAX(Commodities[Date1]),
        Commodities[Date1] < EARLIER(Commodities[Date1]),
        ALLEXCEPT(Commodities,Commodities[Navistar Steel CRU Index Cost/lb])
    )
    VAR PreviousValue_ =
        CALCULATE(
            DISTINCT(Commodities[Navistar Steel CRU Index Cost/lb]),
            Commodities[Date1] = PreviousDate_,
            ALLEXCEPT(Commodities,Commodities[Navistar Steel CRU Index Cost/lb])
        )
    VAR CurrentValue_ = Commodities[Navistar Steel CRU Index Cost/lb]
    RETURN
        IF(
            NOT ISBLANK(CurrentValue_) && NOT   ISBLANK(PreviousValue_),
            CurrentValue_ - PreviousValue_
)
 
The adjustment column is the only one I need help with.  I got the formula to work but I need it to fill in all rows not leave zeros., but also add a 3% threshold to the formula.  
 
example.xlsx  - not sure if link will work or not.
 
Thank you!

That link takes me to a log-in page.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Sorry.  I can send another pic.  But basically the the code below works for me except it is not filling in all the rows.  Do you know why or what I need to change to get the rows to fill in? 

 

Thank you!

Hi,

I will need a file to work with.  So share the download link of the file with your Excel formulas intact.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi,

  1. I wonder what is the use of the IF() function in column D when the result is the same in the value if true and value if false placeholders i.e. $C$56-$C$55
  2. What should the trigger be for changing the range reference of the average function in column D i.e. when the number in column C changes
  3. Why does the first set of coloured cells in column D have 7 rows and the other sets have only 6 rows?

Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi,

I cannot understand the logic of the average formula which you have written in column C.  Please explain that clearly.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Column C don't matter.  that code is working exactly how I need it to in powerbi.  I need a code to calculate the adjustment from column C with a 3% threshold.  the average is a look back period and the adjustment is the difference between the two periods.  I have the code working, it just isnt filling in all the rows with "same" number for the 6 months.  Either I need to take something out of my code or add something to get this to work.  That is  what I am asking.  To alter the code that I already that is working.  Thank you

VAR PreviousDate_ =
    CALCULATE(
        MAX(Commodities[Date1]),
        Commodities[Date1] < EARLIER(Commodities[Date1]),
        ALLEXCEPT(Commodities,Commodities[Navistar Steel CRU Index Cost/lb])
    )
    VAR PreviousValue_ =
        CALCULATE(
            DISTINCT(Commodities[Navistar Steel CRU Index Cost/lb]),
            Commodities[Date1] = PreviousDate_,
            ALLEXCEPT(Commodities,Commodities[Navistar Steel CRU Index Cost/lb])
        )
    VAR CurrentValue_ = Commodities[Navistar Steel CRU Index Cost/lb]
    RETURN
        IF(
            NOT ISBLANK(CurrentValue_) && NOT   ISBLANK(PreviousValue_),
            CurrentValue_ - PreviousValue_
)
yaya1974
Helper III
Helper III

Hi I got it to work with this formula, but I need it to fill in all the rows.  Can someone help with that?

Plus I am still working on the 3% threshold, if anyone can help to add that in as well  🙂

yaya1974_0-1721334574582.png

Thank you!!

 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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
Top Kudoed Authors