Buenos días,
soy nueva en power BI y no entiendo muy bien el lenguaje de DAX.
Estoy haciendo una medida para que una columna se ponga de un color u otro dependiendo del valor que tenga.
De momento he hecho esto:
COLOR= SWITCH(TRUE(), SUM(COSTE) > SUM (META COSTE), "#039800", SUM(COSTE)< SUM(META COSTE), "#DF0000")
Es decir, que si mi coste es mayor que la meta, se ponga de un color, pero si es menor se ponga de otro. Hasta aquí todo bien.
Pero necesito hacer un doble condicional, es decir, necesito poner que si el coste> a la meta se ponga de un color, pero que si el coste es < que la meta Y ADEMÁS > coste del año anterior se ponga en otro color, y que si el coste es< que la meta Y ADEMÁS < que el coste del año anterior se ponga de otro distinto. Es decir, 3 colores
Lo he intententado de varias formas y no hay manera con ese formato, muchas gracias por la ayuda.
Solved! Go to Solution.
@blancadeamuriza , Based on what I got so far.
You can add additional condition is and && or OR ||
COLOR= SWITCH(TRUE(), SUM(COSTE) > SUM (META COSTE) && SUM(Previous year COSTE) > SUM (META COSTE) , "#039800",
SUM(COSTE)< SUM(META COSTE), "#DF0000")
for last year cost you can use time intelligence with date table
example
Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Year))
Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),SAMEPERIODLASTYEAR('Date'[Date]))
To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.
Hi @blancadeamuriza ,
I have built a data sample,
......
Please follow @amitchandak 's suggestion to calculate the last year cost:
Last year cost = CALCULATE(SUM('Table'[Cost]),SAMEPERIODLASTYEAR('Table'[Date]))
Then try:
Color =
var _cost=SUM('Table'[Cost])
var _target=SUM('Table'[Target])
return
SWITCH(TRUE(), _cost>_target,"Red", _cost<_target && _cost>[Last year cost], "Green", _cost<=_target &&_cost<=[Last year cost], "Yellow")
Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @blancadeamuriza ,
I have built a data sample,
......
Please follow @amitchandak 's suggestion to calculate the last year cost:
Last year cost = CALCULATE(SUM('Table'[Cost]),SAMEPERIODLASTYEAR('Table'[Date]))
Then try:
Color =
var _cost=SUM('Table'[Cost])
var _target=SUM('Table'[Target])
return
SWITCH(TRUE(), _cost>_target,"Red", _cost<_target && _cost>[Last year cost], "Green", _cost<=_target &&_cost<=[Last year cost], "Yellow")
Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@blancadeamuriza , Based on what I got so far.
You can add additional condition is and && or OR ||
COLOR= SWITCH(TRUE(), SUM(COSTE) > SUM (META COSTE) && SUM(Previous year COSTE) > SUM (META COSTE) , "#039800",
SUM(COSTE)< SUM(META COSTE), "#DF0000")
for last year cost you can use time intelligence with date table
example
Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Year))
Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),SAMEPERIODLASTYEAR('Date'[Date]))
To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.
User | Count |
---|---|
123 | |
62 | |
56 | |
47 | |
42 |
User | Count |
---|---|
113 | |
65 | |
61 | |
54 | |
45 |