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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Victor1986
Helper I
Helper I

Formatação condicional com dax

Bom dia!

Gostaria de calcular os grupos abaixo aplicando a seguinte regra:

Se coluna GRUPO = Estado < 200 ERB's for maior que 15% (coluna  %ERB´'s)  então pinta de laranja 

Se coluna GRUPO= Estado < 200 ERB's for maior que 25%  (coluna  %ERB´'s) então pinta de vermelho

Se não for maior que 15% e maior que 25% então deixar em branco.

 

Outro exemplo da caluna GRUPO ...

Se coluna GRUPO = Estado > 200 < 500 ERB's for maior que 15% (coluna  %ERB´'s)  então pinta de laranja

Se coluna GRUPO = Estado > 200 < 500 ERB's for maior que 25% (coluna  %ERB´'s)  então pinta de vermelho

Victor1986_0-1664801823956.png

 

1 ACCEPTED SOLUTION

Hi , @Victor1986 

Based on the dax you wrote, I don't think there's anything wrong with your logic, you need to check the following points:

(1)Make sure you're writing Measure and putting it in the visual.

(2)Check if your [%ERB's] field format is a number type

(3)For the data you provide '2,35%' specifically means a few percent, you need to replace your comparison value yourself.(For your format '0,00%', I'm not very clear what the specific values represent)

 

Best Regards,

Aniya Zhang

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

7 REPLIES 7
fahenrique
New Member

Olá, pessoal! Se você está interessado em aprimorar suas habilidades no Power BI, temos um vídeo super útil sobre formatação condicional que pode ajudar a tornar seus relatórios ainda mais dinâmicos e informativos:  https://www.instagram.com/p/C7hm_e_Ir3t/

Além disso, no nosso blog da inQuesti, você encontrará uma variedade de conteúdos sobre Power BI que podem ajudar a otimizar suas análises e a criação de dashboards. Vale a pena conferir!
https://inquesti.com.br/blog/

v-yueyunzh-msft
Community Support
Community Support

Hi , @Victor1986 

According to your description , you want to show different colors according to different conditions. Right?

Here are the steps you can refer to :
(1)This is my test data:

vyueyunzhmsft_0-1664849144550.png

(2)We can create a measure:

Measure = var _grupo=SELECTEDVALUE('Sheet1'[GRUPO]) 
var _erb  =SELECTEDVALUE('Sheet1'[%ERB's])
return 
SWITCH(TRUE(), 
_grupo = "Estado < 200 ERB's" , IF(_erb > 0.15 && _erb <0.25 , "orange" , IF(_erb >= 0.25 ,"red" , BLANK())),
_grupo = "Estado > 200 < 500 ERB's" , IF(_erb > 0.15 && _erb <0.25 , "orange" , IF(_erb >= 0.25 ,"red" , BLANK())),BLANK())

(3)We can put the measure to which filed we want to diplay colors:

vyueyunzhmsft_1-1664849220438.png

vyueyunzhmsft_2-1664849234303.png

(4)Then we can meet your need , the result is as follows:

vyueyunzhmsft_3-1664849260453.png

 

If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem.

 

Best Regards,

Aniya Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

 

 

Olá @v-yueyunzh-msft 

Tudo bem?

utilizei a formula dax mencionada por vc conforme abaixo...no entando quando vou aplicala como formatação condicional aparece como não selecionavel... consegue me orientar aonde esta o erro e porque esta não selecionavel?

 

Victor1986_0-1664894750133.png

 

Format Cond =
var _grupo = SELECTEDVALUE('TOTAL ERBS UF'[GRUPO])
var _erb = SELECTEDVALUE('TOTAL ERBS UF'[%ERB's])
return
SWITCH(TRUE(),
_grupo = "Estado < 200 ERB's", IF(_erb > 0.15 && _erb <0.25 , "orange" , IF(_erb >= 0.25 ,"red" , BLANK())),
_grupo = "Estado > 200 < 500 ERB's" , IF(_erb > 0.15 && _erb <0.25 , "orange" , IF(_erb >= 0.25 ,"red" , BLANK())),BLANK())

 

Hi, @Victor1986 

If you use the measure to display the color, you need to select "Field value" in "Format style".

vyueyunzhmsft_0-1664932183910.png

 

Best Regards,

Aniya Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

 

Bom dia @v-yueyunzh-msft 

 

Segui com o preenchimento da formula conforme abaixo e tambem utilizei como "valor do campo" ... a formula não apresentou erro e tambem não representou as cores.....

Victor1986_0-1664969860182.png

Formula:

 

Cond =
var _grupo = SELECTEDVALUE('TOTAL ERBS UF'[GRUPO])
var _erb = SELECTEDVALUE('TOTAL ERBS UF'[%ERB's])
return
SWITCH(TRUE(),
_grupo = "Estado < 200 ERB's", IF(_erb > 0.15 && _erb <0.25 , "orange" , IF(_erb >= 0.25 ,"red" , BLANK())),
_grupo = "Estado > 200 < 500 ERB's" , IF(_erb > 0.15 && _erb <0.25 , "orange" , IF(_erb >= 0.25 ,"red" , BLANK())),
_grupo = "Estado > 500 < 750 ERB's" , IF(_erb > 0.15 && _erb <0.25 , "orange" , IF(_erb >= 0.25 ,"red" , BLANK())),
_grupo = "Estado > 750 < 1000 ERB's" , IF(_erb > 0.15 && _erb <0.25 , "orange" , IF(_erb >= 0.25 ,"red" , BLANK())),
_grupo = "Estado > 1000 < 2500 ERB's" , IF(_erb > 0.15 && _erb <0.25 , "orange" , IF(_erb >= 0.25 ,"red" , BLANK())),
_grupo = "Estado > 2500 ERB's" , IF(_erb > 0.15 && _erb <0.25 , "orange" , IF(_erb >= 0.25 ,"red" , BLANK())),BLANK())

Hi , @Victor1986 

Based on the dax you wrote, I don't think there's anything wrong with your logic, you need to check the following points:

(1)Make sure you're writing Measure and putting it in the visual.

(2)Check if your [%ERB's] field format is a number type

(3)For the data you provide '2,35%' specifically means a few percent, you need to replace your comparison value yourself.(For your format '0,00%', I'm not very clear what the specific values represent)

 

Best Regards,

Aniya Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Desculpa, eu escrevo uma coisa aqui e publica outra diferente do que escrevi ...mais acho que vc entendeu .....

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.