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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
AShiraz2023
Frequent Visitor

DAX measure to find monthly price change.

Hello All,

I am working on transactional data and product price change monthly or sometime every 2nd or 3rd month it can go up or down. I try to write dax measure in excel data model but the result is not what i need. can someone help? here is the data i am working with.

 

DimkeyPartlistIndexEnd of MonthPriceCurrencyPrice Changerequired result

DimkeyPartlistIndexEnd of MonthPriceCurrencyPrice Changerequired result
33299Product002018-01-311.0839USD0.00160
33301Product002018-02-281.0839USD0.00160
33297Product002018-03-311.0839USD0.00160
33294Product002018-04-301.0839USD0.00160
33295Product002018-05-311.0839USD0.00160
33293Product002018-06-301.0839USD0.00160
33296Product002018-07-311.0839USD0.00160
33292Product002018-08-311.0855USD0.00160.0016
33302Product002018-09-301.0855USD0.00160
33300Product002018-10-311.0855USD0.00160
33303Product002018-11-301.0855USD0.00160
33298Product002018-12-311.0855USD0.00160
31746Product112018-01-317.96USD0.360
31745Product112018-02-287.96USD0.360
31748Product112018-03-317.96USD0.360
31752Product112018-04-308.06USD0.360.1
31751Product112018-05-318.06USD0.360
31754Product112018-06-308.32USD0.360.26
31747Product112018-07-318.32USD0.360
31744Product112018-08-318.32USD0.360
31753Product112018-09-308.32USD0.360
31743Product112018-10-318.24USD0.36-0.08
31750Product112018-11-308.24USD0.360
31749Product112018-12-318.09USD0.36-0.15
        

Current DAX measure:
Monthly Price Change:=VAR MaxDate = MAX(PriceChange[End of Month])
VAR MinDate = MIN(PriceChange[End of Month])
VAR MaxPrice = CALCULATE(MAX(PriceChange[PO Price]), ALLEXCEPT(PriceChange, PriceChange[Partlist]))
VAR MinPrice = CALCULATE(MIN(PriceChange[PO Price]), ALLEXCEPT(PriceChange, PriceChange[Partlist]))
RETURN
IF(ISBLANK(MaxPrice) || ISBLANK(MinPrice), BLANK(), MaxPrice - MinPrice)

 

where price change occur: based on date column price diffrence need to calculated
 
price change result with DAX measure (current result with above dax measure
 
required result: Result i am looking for.

 

thank you for your help in advance.

1 ACCEPTED SOLUTION

Hi @AShiraz2023 for forecasting in Power BI please check link

Use the Analytics pane in Power BI Desktop - Power BI | Microsoft Learn

If solution above is working please accept solution so other member of community could use it. Thank you.





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

Proud to be a Super User!






View solution in original post

7 REPLIES 7
AShiraz2023
Frequent Visitor

Hello @some_bih, above sloution works for MOM change, thank you. however when i add previous month column to my pivot table it doesn't show any number. can you let me know how can i fix this issue. in addition to that since my data is coming from part receiving table smetime i don't receive part in 2 consecutive month like part recived in Jan than March or April insted of Feb. is there anyway i can filter parts if its not recienved in particular month and show only items price varience where part recived because with your current sloution if i don't recived part than it shows blank value in sum of price and rest of the measure. thank you in advance for your help.

Hi @AShiraz2023 I did as it was shown on example.

For your new scenario:

- adding new columns - please not that MOM measure should work when there is some columns from Date / Calendar table. So use columns for year / month from your Calendar / date table.

- I do not know details how you prepare your data. Measure should work as we use columns for year / month from your Calendar / date table where there are consecutive dates. In this scenario you will have just lag of months for data, but caclculation should work.

Did I answer correctly? Kudos appreciate / accept solution.

 





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

Proud to be a Super User!






I import my part receving data from folder using power query. it shows all spend columns such as part, plant, category, subcategory vandor, quantity, price, and part reciving date, than i load to data model in excel and create date table as you mention before. now i  run analysis on mom price change as per your sloution. next i need to add some dax measure to analysis monthly and annual spend by category and vendor or subcategory ect. once this is done than based on quantity column i like to create forecast for each part lets say for next 5 year based on current usage. is this possible?

Hello @some_bih , Tank you for solving the issue. is there anyway i can workaround and genrate forecast in excel data model since i am not using power bi? 

Hi @AShiraz2023 in Excel, sure. Example is on the link below. On web there are many resources for forecastin in Excel.

FORECAST Function in Excel (Example, Formula) | How to use? (wallstreetmojo.com)





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

Proud to be a Super User!






Hi @AShiraz2023 for forecasting in Power BI please check link

Use the Analytics pane in Power BI Desktop - Power BI | Microsoft Learn

If solution above is working please accept solution so other member of community could use it. Thank you.





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

Proud to be a Super User!






some_bih
Super User
Super User

Hi @AShiraz2023 for you case please create Calendar / Date table, if you already do not have one in the model and create relationship, then create measures as below. Output should be as your.

Did I answer correctly? Kudos appreciate / accept solution.

Sum of Price = SUM(Sheet1[Price])
PM Sum of Price =
 //previous month price
    CALCULATE (
        [Sum of Price],
        CALCULATETABLE (
            DATEADD ( 'Date'[Date], -1, MONTH )
        )
    )
MOM Change in price =
//calculation of change in price month over month
VAR __current_month = [Sum of Price]
VAR __previous_month = [PM Sum of Price]
VAR __Result =
    IF (
        NOT ISBLANK ( __current_month ) && NOT ISBLANK ( __previous_month ),
        __current_month - __previous_month,
        0
)
RETURN
__Result
 Output
some_bih_0-1693859892205.png

 





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

Proud to be a Super User!






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.