Forum Discussion
Función Switch
Estoy teniendo problemas con esta fórmula. Me funciona cuando el año seleccionado no es 2021 pero, cuando el año es 2021 no me funciona. ¿Veis algo mal?
Hey 94veiga ,
you use expressions like that:
NOW() > 2021/01/01In Power BI 2021/01/01 written like that is a mathematical operation. In this case 2021 is divided by 1 and the result is divided by 1. So the comparison is if NOW() > 2021 and that's never true.
For that reason it's now working.
You have to use the DATE function to create a new date. This would work:
NOW() > DATE( 2021, 01, 01 )You could also check about the current month:
Falta = SWITCH( TRUE(), MONTH( NOW() ) in {1, 2, 3} && [Frequencia] = "Trimestral", "Trimestre pendiente", MONTH( NOW() ) in {4, 5, 6} && [Frequencia] = "Trimestral", "Trimestrependiente", ...)If you need any help please let me know.If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍Best regardsDenisBlog: WhatTheFact.biFollow me: twitter.com/DenSelimovic
1 Reply
- selimovd
Most Valuable Professional
Hey 94veiga ,
you use expressions like that:
NOW() > 2021/01/01In Power BI 2021/01/01 written like that is a mathematical operation. In this case 2021 is divided by 1 and the result is divided by 1. So the comparison is if NOW() > 2021 and that's never true.
For that reason it's now working.
You have to use the DATE function to create a new date. This would work:
NOW() > DATE( 2021, 01, 01 )You could also check about the current month:
Falta = SWITCH( TRUE(), MONTH( NOW() ) in {1, 2, 3} && [Frequencia] = "Trimestral", "Trimestre pendiente", MONTH( NOW() ) in {4, 5, 6} && [Frequencia] = "Trimestral", "Trimestrependiente", ...)If you need any help please let me know.If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍Best regardsDenisBlog: WhatTheFact.biFollow me: twitter.com/DenSelimovic