Forum Discussion
Dynamic Measure and using her in one calculation
- 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!
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!
Hi brunozanoelo
Thanks for the reply from VahidDM .
brunozanoelo, good to know that you have solved the previous problem, for the problem you are facing now, if I understand correctly, do you need to make the data automatically into the corresponding format based on the Field parameter's options? I can't reproduce your scenario with the information so far, could you please provide some sample data and the expected results based on the sample data? How to provide sample data in the Power BI Forum - Microsoft Fabric Community Or show them as screenshots or pbix. Please remove any sensitive data in advance. If uploading pbix files please do not log into your account.
Best Regards,
Yulia Xu