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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
jgap98
Regular Visitor

Competitiveness index

Hi all, 

 

I'm having some trouble with the Dax logic. I have a data set, which I don't have access right now, but the structure is simple:

 

Data - product ID - product description - brand - paid price

 

Each observation is a sold product. It is not grouped by quantity. 

My objective is to group these events by date and brand, calculate the average price by brand, and also an competiveness index, which I'm struggling to create.

 

The index reasoning is not a big deal, I want to use a specific brand as a reference and calculate the relativity between the other brands. 

For example, I have three brands, (Nike, adidas, puma). Referencing "Nike" as an example, I would like to divide the avg price from Adidas and puma separately, and as a final result understand the relativity between the brands.

 

Using Dax, I tried doing the following:

"compt:= IF(table[brand] ="Nike", 1, table[price] / Calculate(Average(table[price]), Filter(table, table[brand] = "Nike" "

 

My objective here was to normalize my reference and then divide each observation, so I could obtain the result for each brand. 

The result is not what I expect, usually the result is always "infinite"

 

Unfortunately I really don't have the data available at this moment, but later I would be able to update the section if needed.

I would appreciate all the help, and tips, since I'm a new user, it is always a challenge. 

Thanks!

 

2 REPLIES 2
jgap98
Regular Visitor

@amitchandak, thanks for the reply, unfortunately it didn't work.

 

I could achieve some success by creating a calculated column and applying the formula below:

 

compt_index = DIVIDE(InfoPrice[PrecoPadrao], 
                CALCULATE(
                    AVERAGEX(InfoPrice, InfoPrice[avg_price_brand]),
                        FILTER(InfoPrice, InfoPrice[Marca] = "Brand1"), 
                        FILTER(InfoPrice, InfoPrice[Data].[Ano] = EARLIER(InfoPrice[Data].[Ano])),
                        FILTER(InfoPrice, InfoPrice[Data].[Mês] = EARLIER(InfoPrice[Data].[Mês]))
                        )
                    )              

 

*[avg_price_brand] is another calculated column that is just the avg price of the whole table.

 

It works in a scenario that i don't have filters other than data, which i could achieve by using the earlier function.

Year2022 Year2023
 Avg. PriceAvg. Of Competiveness IndexAvg. PriceAvg. Of Competiveness Index
Brand13,920,624,130,6
Brand24,430,74,500,66
Brand36,110,976,110,89
Brand45,250,835,250,77
Brand56,401,026,200,91
Brand66,3116,841

 

However, i have other segmentation filters that the user will be able to choose, for example, "State", "Packing size", "Brand" and/or "Volume".

These addtional filters didn't work in a calculated column by including the same FILTER() formula and assigning the SELECTEDVALUE(InfoPrice[State]) but no success at all.

I also tried to include this formula in a measure, but the earlier function does not fit in it, formula below:

 

compt_ind_2 = 
    var preco_ref = 
            CALCULATE(AVERAGEX(InfoPrice, InfoPrice[price]), 
                FILTER(InfoPrice, InfoPrice[Marca] = "brand4")
        )

    var avg_marcas = 
        VAR flt_uf = SELECTEDVALUE(Aux_UF[DescUF])
        VAR flt_emb = SELECTEDVALUE(Aux_Produtos[Pack_size])
        VAR flt_vol = SELECTEDVALUE(Aux_Produtos[Volume])
        VAR flt_channel = SELECTEDVALUE(Aux_TipoDeLoja[TipoPadrao])
        RETURN
        CALCULATE(AVERAGEX(InfoPrice, InfoPrice[brand]),
            FILTER(InfoPrice, InfoPrice[brand]), InfoPrice[brand],
                Aux_UF[DescUF] = flt_uf,
                Aux_Produtos[pack_size] = flt_emb,
                Aux_Produtos[Volume] = flt_vol,
                Aux_TipoDeLoja[TipoPadrao] = flt_channel
            
            )
    var compt_ind = 
        DIVIDE(avg_marcas, preco_ref)
return compt_ind

 

 

Any ideas on how to proceed?

Thanks!

João

amitchandak
Super User
Super User

@jgap98 , Based on what I got  measure like

 

Calculate( calculate(Averagex(Values(Table[Brand]) , calculate(Average(Table[Price]) ) )

, allselected())

 

or

 

calculate(

calculate(Averagex(Values(Table[Brand]) , calculate(Average(Table[Price]), filter(Table[Brand] <>Max(Table[Brand] ) )

, allselected())

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

AugPowerBI_Carousel

Power BI Monthly Update - August 2024

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

August Carousel

Fabric Community Update - August 2024

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