Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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

Reply
John_Silva642
Frequent Visitor

FORMAT result according with filter and put It in a bar chart

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

 

 

John_Silva642_0-1671743391427.png

John_Silva642_1-1671743781008.png

Just _RESULT

John_Silva642_2-1671744324328.png

 

1 ACCEPTED SOLUTION
v-jianboli-msft
Community Support
Community Support

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:

vjianbolimsft_0-1672209363671.png

Then apply to the visual:

vjianbolimsft_2-1672209433577.png

vjianbolimsft_3-1672209450705.png

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.

View solution in original post

4 REPLIES 4
v-jianboli-msft
Community Support
Community Support

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:

vjianbolimsft_0-1672209363671.png

Then apply to the visual:

vjianbolimsft_2-1672209433577.png

vjianbolimsft_3-1672209450705.png

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!

v-jianboli-msft
Community Support
Community Support

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:

vjianbolimsft_0-1671758206855.png

Output:

vjianbolimsft_1-1671758223776.png

 

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:

John_Silva642_0-1671807806409.png

Percent FORMAT (Standard)

John_Silva642_1-1671807847089.png

Percent FORMAT (0.000%)

John_Silva642_2-1671807891242.png

Percent FORMAT (Percent)




Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

Check out the October 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

Find out what's new and trending in the Fabric Community.