Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
I have the following Table, with a Dynamic Parameter that changes the measure used in graphs:
Solved! Go to Solution.
@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!
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
@VahidDM Hello Vahid, I´m trying the solution proposed in this article's but I´ve not suceeded yet.
https://community.fabric.microsoft.com/t5/Desktop/Field-Parameters-Dynamic-Visual-Title/td-p/2529607
https://www.sqlbi.com/blog/marco/2022/06/11/using-selectedvalue-with-fields-parameters-in-power-bi/
Hard to find an workaround.
Short Answer:
Use a SWITCH function to map the selected text value to the corresponding measure, and then reference that measure in your calculations. For sorting, consider using a numeric column in the parameter table or field parameters for dynamic sorting.
Detailed Steps:
Map the Selected Parameter to a Measure:
Instead of returning a string measure name, use a SWITCH in a measure to choose the corresponding numeric measure. For example:
SelectedMeasureValue =
SWITCH(
SELECTEDVALUE('Dimensão de Valores'[Dimensão de Valores]),
"Valor de Venda", [Valor Total de Venda],
"Quantidade (PE)", [Total Quantidade (PE)],
"Quantidade", [Total Quantidade],
"Peso Bruto", [Total Peso Bruto],
"Peso Líquido", [Total Peso Líquido],
BLANK()
)
Now SelectedMeasureValue returns the actual numeric measure, not text.
Use the Mapped Measure in Calculations: Your existing calculation:
IF(
MIN(Vendas[Ano]) = MAX(Vendas[Ano]),
BLANK(),
CALCULATE(
SUM(Movimentos[Valor de Venda]),
FILTER(Vendas, Vendas[Ano] = MIN(Vendas[Ano]))
)
)
Replace SUM(Movimentos[Valor de Venda]) with your new SelectedMeasureValue:
DynamicCalculation =
IF(
MIN(Vendas[Ano]) = MAX(Vendas[Ano]),
BLANK(),
CALCULATE(
[SelectedMeasureValue],
FILTER(Vendas, Vendas[Ano] = MIN(Vendas[Ano]))
)
)
Handle Sorting: For sorting issues:
By using a SWITCH measure, you dynamically select the appropriate measure based on the parameter selection, enabling both correct aggregation and easier control over sorting.
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn|Twitter|Blog |YouTube
Hello @VahidDM ! It´s a pleasure to meet you, thank you for your help.
I tried the following solution and appears to work, until the part of the calculation, PowerBI Desktop gives me this error on visuals:
Error fetching data for this visual:
MdxScript(Model) (195, 5) Calculation error in the measure "Dimensão de Valores"[SelectedMeasureValue]: A [Values] is part of the composite column key, but not all columns in the composite key are included in the expression or its dependent expression.
Any suggestion?
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
21 | |
15 | |
14 | |
11 | |
7 |
User | Count |
---|---|
25 | |
24 | |
12 | |
12 | |
11 |