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
sujana_m
Frequent Visitor

Calculating Price Difference between SKUs

Hi,

 

I need help calculating the price difference between pack sizes of the same SKU. Below is the sample output I received:

 

sujana_m_0-1707784826253.png

 

The values in Price difference are partially correct. There is no discrepancies in data.

 

Below is the measure I tried to get this output:

 

CIA PriceDifference =
VAR CRSellUnit = MIN('PRODUCT'[SELL_UNIT])
VAR CRPrice_IV = ([CIA Price Per Unit])
VAR PRSellUnit =
    CALCULATE(
        MAX('PRODUCT'[SELL_UNIT]),
        FILTER(
            ALL('PRODUCT'[PACKAGING_CATEGORY],'PRODUCT'[SELL_UNIT],'PRODUCT'[UNIT_VOLUME_ML]),
            'PRODUCT'[SELL_UNIT] < CRSellUnit
        )
    )
VAR PRPrice_FV =
    CALCULATE(
        ([CIA Price Per Unit]),
        FILTER(
            ALL('PRODUCT'[PACKAGING_CATEGORY],'PRODUCT'[SELL_UNIT],'PRODUCT'[UNIT_VOLUME_ML]),
            'PRODUCT'[SELL_UNIT] = PRSellUnit
        )
    )
RETURN
    IF(ISBLANK(PRPrice_FV), BLANK(), PRPrice_FV - CRPrice_IV)

 

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi, 

I am not sure how the semantic model looks like, but please try something like below if it suits your requirement.

 

CIA PriceDifference =
VAR CRSellUnit =
    MIN ( 'PRODUCT'[SELL_UNIT] )
VAR CRPrice_IV = [CIA Price Per Unit]
VAR PRSellUnit =
    MAXX (
        FILTER ( ALL ( 'PRODUCT'[SELL_UNIT] ), 'PRODUCT'[SELL_UNIT] < CRSellUnit ),
        'PRODUCT'[SELL_UNIT]
    )
VAR PRPrice_FV =
    CALCULATE ( [CIA Price Per Unit], 'PRODUCT'[SELL_UNIT] = PRSellUnit )
RETURN
    IF ( ISBLANK ( PRPrice_FV ), BLANK (), PRPrice_FV - CRPrice_IV )

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.

sujana_m_0-1707833340511.png


This is the output I am getting.

Here is a snapshot of the model:

model.JPG

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.