Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I am trying to update background color of a column in PowerBi report. For that I am trying to create a column in power BI report and adding a switch statement to display background as
Red if dates greater than 2 weeks
Green if dates less than 2 weeks etc.,
The switch statement is working fine for strings but not with dates. Any suggestion or pointer would help to make dates switch work.
Working Switch
for string conditions by creating a new column
columnNameColorNumber = SWITCH(MyData[name],"abc",1,"def",2,3)
New column shows numbers as expected
Failing Switch when trying to create a column in power bi with date conditions
columnNameColorNumber = SWITCH(MyData[reqDate],"(MyData[reqDate]>(Today()-14))",1,2)
New column shows error
columnNameColorNumber = SWITCH(TRUE(),MyData[reqDate]>Today()-14,1,2)
to add more switch checks it would look like this:
columnNameColorNumber = SWITCH(TRUE(),
MyData[reqDate]>Today()-14,1,
MyData[reqDate]>Today()-30,2,3)
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.