Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now
Hi,
I'm trying to create a code that FORMAT the result according to the selected filter.
My code works on cards, but It doesn't work on the bar charts.
Can someone help me, please?
Below there is the DAX code and a data model example.
PERFORMED_BY_TOTAL_TWELVEMONTHS = VAR _LASTREF = CALCULATE( MAX('DBN'[Data]), 'DBN'[Tipo] = "PERFORMED/TOTAL", 'DBN'[Valor] <> BLANK() ) VAR _ELEVENMONTHSAGO = EDATE(_LASTREF,-11) VAR _INDICATOR = CALCULATE( SELECTEDVALUE('DBN'[KPI], "ERROR"), 'DBN'[Tipo] = "PERFORMED/TOTAL" ) VAR _RESULT = CALCULATE( SUM('DBN'[Valor]), 'DBN'[Tipo] = "PERFORMED/TOTAL", 'DBN'[Data] >= _ELEVENMONTHSAGO && 'DBN'[Data] <= _LASTREF ) VAR _FORMAT = IF( _INDICATOR = "% Valor pendente", FORMAT(_RESULT, "0.000%"), IF( _INDICATOR = "Quantidade Propostas Eletrônicas Total", FORMAT(_RESULT, "Standard"), FORMAT(_RESULT, "Percent") ) ) RETURN _FORMAT |
Just _RESULT
Solved! Go to Solution.
Hi @John_Silva642 ,
Have you ever considered about using field parameter?
Field parameters allow users to dynamically change the measures or dimensions being analyzed within a report. This feature can help your report readers explore and customize the analysis of the report by selecting the different measures or dimensions they're interested in.
For example:
Then apply to the visual:
For more details, please refer to:
Let report readers use field parameters to change visuals (preview) - Power BI | Microsoft Learn
Best Regards,
Jianbo Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @John_Silva642 ,
Have you ever considered about using field parameter?
Field parameters allow users to dynamically change the measures or dimensions being analyzed within a report. This feature can help your report readers explore and customize the analysis of the report by selecting the different measures or dimensions they're interested in.
For example:
Then apply to the visual:
For more details, please refer to:
Let report readers use field parameters to change visuals (preview) - Power BI | Microsoft Learn
Best Regards,
Jianbo Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
It solved my problem. Thank you!
Hi @John_Silva642 ,
You can't use the Format function in your bar chart because it will convert the values to text format, making it unrecognizable to visual.
For more details, refer to:
FORMAT function (DAX) - DAX | Microsoft Learn
You can change the format of your measure here:
Output:
Best Regards,
Jianbo Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thanks @v-jianboli-msft
But I need something like the FORMAT function to change the result according to the filter.
Example:
Percent FORMAT (Standard)
Percent FORMAT (0.000%)
Percent FORMAT (Percent)
Check out the October 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
115 | |
112 | |
105 | |
95 | |
58 |
User | Count |
---|---|
174 | |
147 | |
136 | |
102 | |
82 |