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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

Divide a value by the value of that product with biggest value on other column

Hello,

 

I have the following table with some measures in it at Product level:

adriandumitru_0-1684245709759.png

I need a measure that will divide every value from Avg Price by the Avg Price of that Product with the biggest MS CY.

Example: for each product every value from AVG Price will be divided by 166.35.

 

I created the following measure to know which Product has the biggest MS CY:

MAX MS = FORMAT( MAXX(ALL('All'[PRODUCT DESCRIPTION]),[MS Butoane SKU]),"General Number")
The result beeing 26%, but I don't know how to substract AVG Price (166.35) of that Product.

 

 

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @Anonymous 
I do apologize as I was answering in a harry without paying much attention. Somehow your question just popped up in my head and I realized I did a stupid mistake in my last code. Please try the following instead:

Result =
DIVIDE (
    [Avg Price],
    MAXX (
        TOPN (
            1,
            ALLSELECTED ( 'All'[PRODUCT DESCRIPTION] ),
            VAR CurrentProduct1 = 'All'[PRODUCT DESCRIPTION]
            RETURN
                CALCULATE ( [MS Butoane SKU], 'All'[PRODUCT DESCRIPTION] = CurrentProduct1 )
        ),
        VAR CurrentProduct2 = 'All'[PRODUCT DESCRIPTION]
        RETURN
            CALCULATE ( [Avg Price], 'All'[PRODUCT DESCRIPTION] = CurrentProduct2 )
    )
)

View solution in original post

7 REPLIES 7
tamerj1
Super User
Super User

Hi @Anonymous 
I do apologize as I was answering in a harry without paying much attention. Somehow your question just popped up in my head and I realized I did a stupid mistake in my last code. Please try the following instead:

Result =
DIVIDE (
    [Avg Price],
    MAXX (
        TOPN (
            1,
            ALLSELECTED ( 'All'[PRODUCT DESCRIPTION] ),
            VAR CurrentProduct1 = 'All'[PRODUCT DESCRIPTION]
            RETURN
                CALCULATE ( [MS Butoane SKU], 'All'[PRODUCT DESCRIPTION] = CurrentProduct1 )
        ),
        VAR CurrentProduct2 = 'All'[PRODUCT DESCRIPTION]
        RETURN
            CALCULATE ( [Avg Price], 'All'[PRODUCT DESCRIPTION] = CurrentProduct2 )
    )
)
Anonymous
Not applicable

Thank you @tamerj1  didn't know you can put variable in the middle of the measure.

tamerj1
Super User
Super User

Hi @Anonymous 

please try

Result =
DIVIDE (
[Avg Price],
MAXX (
SELECTCOLUMNS (
TOPN ( 1, ALL ( 'All'[PRODUCT DESCRIPTION] ), [MS Butoane SKU] ),
"@Avg", [Avg Price]
),
[@Avg]
)
)

Anonymous
Not applicable

Is not working. It gives me 100% for every product. 

adriandumitru_0-1684321273293.png

 

Hi @Anonymous 
Please try

Result =
DIVIDE (
    [Avg Price],
    MAXX (
        SELECTCOLUMNS (
            ALL ( 'All'[PRODUCT DESCRIPTION] ),
            "@Avg", CALCULATE ( [MS Butoane SKU], ALLEXCEPT ( 'All', 'All'[PRODUCT DESCRIPTION] ) )
        ),
        [@Avg]
    )
)
Anonymous
Not applicable

This is the result I need:

Avg Price for every product needs to be divided by the Avg Price of that Product with the highest MS.

In this example, the highest MS is 26%, so every row will be divided by 166.346. On row 33 will have 100% because it will divide 166.346 by 166.346.

Depending on the slicer filter with category, the highest MS for that category will change.

adriandumitru_0-1684326148294.png

 

@Anonymous 
Please try

Result =
DIVIDE (
    [Avg Price],
    MAXX (
        TOPN (
            1,
            ALL ( 'All'[PRODUCT DESCRIPTION] ),
            CALCULATE (
                [MS Butoane SKU],
                'All'[PRODUCT DESCRIPTION] = 'All'[PRODUCT DESCRIPTION]
            )
        ),
        CALCULATE (
            [Avg Price],
            'All'[PRODUCT DESCRIPTION] = 'All'[PRODUCT DESCRIPTION]
        )
    )
)

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.