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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Johnny78968798
Frequent Visitor

Calculate difference between multiple values in same column based on week of column

Im trying to create a new column (Price Delta) that calculates the difference between price of the 5 different Brands (R, D, G, C, P) and the "Other Avg" for each week.

 

Example for week of 1/1/24:

Brand R price (16.6) minus Other Avg price (14.8) = Price Delta (1.8)

Brand D price (14.4) minus Other Avg price (14.8) = Price Delta (-0.4)

etc... 

 

This should done for each week based on that weekly "Other Avg" value

 

Here is the data set I'm referring to and the desired column in red with desired values:

 

YearWeekWeek OfBrandPricePrice Delta
202411/1/24Brand R16.61.8
202411/1/24Brand D14.4-0.4
202411/1/24Brand G13.4-1.4
202411/1/24Brand C17.52.7
202411/1/24Brand P16.61.8
202411/1/24Other Avg14.8 
202421/8/24Brand R17.53.2
202421/8/24Brand D13.8-0.5
202421/8/24Brand G13.3-1.0
202421/8/24Brand C17.33.0
202421/8/24Brand P16.92.6
202421/8/24Other Avg14.3 

 

Thanks in advance!

1 ACCEPTED SOLUTION
DataNinja777
Super User
Super User

Hi @Johnny78968798 ,

You can produce your required output by writing a calculated column like below:

 

Price Delta Calculated = 
VAR CurrentWeek = TableName[Week]
VAR OtherAvgPrice =
    CALCULATE(
        MAX(TableName[Price]),
        FILTER(
            TableName,
            TableName[Week] = CurrentWeek && TableName[Brand] = "Other Avg"
        )
    )
RETURN
 [Price] - IF(
        TableName[Brand] <> "Other Avg",
        OtherAvgPrice,
        BLANK()
    )

 

 

DataNinja777_0-1727795716061.png

I have attached an example pbix file.

 

Best regards,

View solution in original post

4 REPLIES 4
DataNinja777
Super User
Super User

Hi @Johnny78968798 ,

You can produce your required output by writing a calculated column like below:

 

Price Delta Calculated = 
VAR CurrentWeek = TableName[Week]
VAR OtherAvgPrice =
    CALCULATE(
        MAX(TableName[Price]),
        FILTER(
            TableName,
            TableName[Week] = CurrentWeek && TableName[Brand] = "Other Avg"
        )
    )
RETURN
 [Price] - IF(
        TableName[Brand] <> "Other Avg",
        OtherAvgPrice,
        BLANK()
    )

 

 

DataNinja777_0-1727795716061.png

I have attached an example pbix file.

 

Best regards,

Worked perfectly! Thank you!

bhanu_gautam
Super User
Super User

@Johnny78968798 , 

Create a new column to calculate the "Price Delta". You can do this by using the CALCULATE and FILTER functions in DAX to get the "Other Avg" price for each week and then subtract it from the price of each brand.

Here is the DAX formula to create the "Price Delta" column:

Price Delta =
VAR CurrentWeek = 'Table'[Week]
VAR OtherAvgPrice =
CALCULATE(
MAX('Table'[Price]),
FILTER(
'Table',
'Table'[Week] = CurrentWeek && 'Table'[Brand] = "Other Avg"
)

 




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Hey @bhanu_gautam 

You didn't paste the end of the measure (missed the Return and actual calculation):

 

Price Delta Forum = 
VAR CurrentWeek = 'Table'[Week]
VAR OtherAvgPrice =
    CALCULATE(
        MAX('Table'[Price]),
        FILTER('Table', 'Table'[Week] = CurrentWeek && 'Table'[Brand] = "Other Avg")
    )
RETURN
OtherAvgPrice-'Table'[Price]

 

Cheers,



If the post helped then please give it a Kudos and mark it as the solution so others can see it.
Cheers,

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.