Forum Discussion
Colour text according to condition
- 3 years ago
Hi, SS_1122
Thank you for your quick response, based on your description you want to show the green and red color according to the return in your card visual. Right?
Here are the steps you can refer to:
(1)This is my test data:
(2)We can create a measure to return the [Successful] of the last date. And we can put the measure on the card visual.
Last Successful = var _date = MAX('Table'[Date]) var _t = FILTER('Table','Table'[Date] =_date) return MAXX(_t,[Successful])(3)We need to create a measure to configure the text color in the card visual.
Color Flag = IF([Last Successful] = "File Submission is successful","green","red")(4)Then we can configure it in the card visual:
Then we can meet your need , the result is as follows:
Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!
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
Hey,
Thank you for your help, I will try and explain the context better.
So, I have a given data with 3 columns - Date, Submitted and Delivered
| Date | Submitted | Delivered |
| 10/10/2022 | 1 | 1 |
| 11/10/2022 | 1 | 1 |
| 12/10/2022 | 1 | 1 |
| 13/10/2022 | 1 | 1 |
| 14/10/2022 | 1 | 1 |
| 15/10/2022 | 1 | 0 |
| 16/10/2022 | 1 | 0 |
| 17/10/2022 | 0 | 0 |
| 18/10/2022 | 0 | 0 |
| 19/10/2022 | 0 | 1 |
| 20/10/2022 | 0 | 1 |
| 21/10/2022 | 0 | 1 |
| 22/10/2022 | 1 | 1 |
| 23/10/2022 | 1 | 0 |
| 24/10/2022 | 1 | 0 |
| 25/10/2022 | 1 | 1 |
| 26/10/2022 | 1 | 1 |
| 27/10/2022 | 1 | 1 |
| 28/10/2022 | 1 | 1 |
| 29/10/2022 | 1 | 1 |
| 30/10/2022 | 1 | 1 |
| 31/10/2022 | 1 | 1 |
| 01/11/2022 | 1 | 0 |
| 02/11/2022 | 1 | 0 |
| 03/11/2022 | 1 | 1 |
| 04/11/2022 | 0 | 1 |
| 05/11/2022 | 1 | 1 |
| 06/11/2022 | 0 | 1 |
| 07/11/2022 | 0 | 1 |
| 08/11/2022 | 1 | 1 |
| 09/11/2022 | 1 | 1 |
Now, I create an additional column by transforming the data in power BI - to add another column whoch measure whether the files have been successfully delivered or not - to check this I write the rule as:
Successful = if(sheet1[Submitted] = 1 && sheet1[Delivered] = 1 , "File Submission is successful" , if (sheet1[Submitted] = 0 && sheet1[Delivered] = 1, "File Submission is not successful" and so on. So, now my data looks something like this
| Date | Submitted | Delivered | Successful |
| 10/10/2022 | 1 | 1 | File Submission is successful |
| 11/10/2022 | 1 | 1 | File Submission is successful |
| 12/10/2022 | 1 | 1 | File Submission is successful |
| 13/10/2022 | 1 | 1 | File Submission is successful |
| 14/10/2022 | 1 | 1 | File Submission is successful |
| 15/10/2022 | 1 | 0 | File Submission is not successful |
| 16/10/2022 | 1 | 0 | File Submission is not successful |
| 17/10/2022 | 0 | 0 | File Submission is not successful |
| 18/10/2022 | 0 | 0 | File Submission is not successful |
| 19/10/2022 | 0 | 1 | File Submission is not successful |
| 20/10/2022 | 0 | 1 | File Submission is not successful |
| 21/10/2022 | 0 | 1 | File Submission is not successful |
| 22/10/2022 | 1 | 1 | File Submission is successful |
| 23/10/2022 | 1 | 0 | File Submission is not successful |
| 24/10/2022 | 1 | 0 | File Submission is not successful |
| 25/10/2022 | 1 | 1 | File Submission is successful |
| 26/10/2022 | 1 | 1 | File Submission is successful |
| 27/10/2022 | 1 | 1 | File Submission is successful |
| 28/10/2022 | 1 | 1 | File Submission is successful |
| 29/10/2022 | 1 | 1 | File Submission is successful |
| 30/10/2022 | 1 | 1 | File Submission is successful |
| 31/10/2022 | 1 | 1 | File Submission is successful |
| 01/11/2022 | 1 | 0 | File Submission is not successful |
| 02/11/2022 | 1 | 0 | File Submission is not successful |
| 03/11/2022 | 1 | 1 | File Submission is successful |
| 04/11/2022 | 0 | 1 | File Submission is not successful |
| 05/11/2022 | 1 | 1 | File Submission is successful |
| 06/11/2022 | 0 | 1 | File Submission is not successful |
| 07/11/2022 | 0 | 1 | File Submission is not successful |
| 08/11/2022 | 1 | 1 | File Submission is successful |
| 09/11/2022 | 1 | 1 | File Submission is successful |
Now I have to create a card based on the last entry, if the last entry says the File Submission is successful =, then it will show something like this.
My only query is how do I colour code the text with green when it says successful and red when not successful.
Hi, SS_1122
Thank you for your quick response, based on your description you want to show the green and red color according to the return in your card visual. Right?
Here are the steps you can refer to:
(1)This is my test data:
(2)We can create a measure to return the [Successful] of the last date. And we can put the measure on the card visual.
Last Successful = var _date = MAX('Table'[Date])
var _t = FILTER('Table','Table'[Date] =_date)
return
MAXX(_t,[Successful])
(3)We need to create a measure to configure the text color in the card visual.
Color Flag = IF([Last Successful] = "File Submission is successful","green","red")
(4)Then we can configure it in the card visual:
Then we can meet your need , the result is as follows:
Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!
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