Forum Discussion
Competitiveness index
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.
| Year | 2022 | Year | 2023 | |
| Avg. Price | Avg. Of Competiveness Index | Avg. Price | Avg. Of Competiveness Index | |
| Brand1 | 3,92 | 0,62 | 4,13 | 0,6 |
| Brand2 | 4,43 | 0,7 | 4,50 | 0,66 |
| Brand3 | 6,11 | 0,97 | 6,11 | 0,89 |
| Brand4 | 5,25 | 0,83 | 5,25 | 0,77 |
| Brand5 | 6,40 | 1,02 | 6,20 | 0,91 |
| Brand6 | 6,31 | 1 | 6,84 | 1 |
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