Forum Discussion

brunozanoelo's avatar
brunozanoelo
Post Patron
1 year ago
Solved

Dynamic Measure and using her in one calculation

I have the following Table, with a Dynamic Parameter that changes the measure used in graphs: Dimensão de Valores = {     ("Valor de Venda", NAMEOF([Valor Total de Venda]), 0),     ("Quantida...
  • brunozanoelo's avatar
    1 year ago

    VahidDM Hello Vahid, I´ve found one solution, using the integer field of my table and not the string one, in this case, PowerBI seens to understand the key.

    MedidaSelecionada = 
    SWITCH(
        SELECTEDVALUE('Dimensão de Valores'[Parâmetro Pedido]),
        0, [Valor Total de Venda],
        1, [Total Quantidade (PE)],
        2, [Total Quantidade],
        3, [Total Peso Bruto],
        4, [Total Peso Líquido],
        BLANK()
    )​


    However, I´m facing now a format problem, since I have Currency (R$) and quantity format, I will change my calcs as the following:

    Valores - Primeiro Ano = IF(
        MIN(Vendas[Ano]) = MAX(Vendas[Ano]),
        BLANK(),
        CALCULATE(
            [MedidaSelecionada],
            FILTER(Vendas, Vendas[Ano] = MIN(Vendas[Ano]))
        )
    )

     

    Valores - Primeiro Ano (Formatado) = 
     SWITCH(
        SELECTEDVALUE('Dimensão de Valores'[Parâmetro Pedido]),
        0, FORMAT([Valores - Primeiro Ano], "R$ #,##00.00"),
        1, FORMAT([Valores - Primeiro Ano], "Standard"),
        2, FORMAT([Valores - Primeiro Ano], "Standard"),
        3, FORMAT([Valores - Primeiro Ano], "Standard"),
        4, FORMAT([Valores - Primeiro Ano], "Standard"),
        BLANK()
    )

     
    It appears to be working fine, in many calculations, however the Format is still and issue that doesn´t get automatically from the field configurations, I need to do it manually in each one of my calcs!

    Thank you for ALL your help Vahid!