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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
SS_1122
Frequent Visitor

Colour text according to condition

Hi All,

I am having a bit of trouble to get this right. I have a data set with dates and 2 columns Submitted and Delivered, if values for both the columns are 1, then file has been "successfully transfered" and if either is not 1 , then it gives something like "Not successful". To achieve this I created a new column in the data to check if both values are 1 or not. Now, I am creating a card based on the new column value which says "successfully transfered" or "not successful" and now based on the above condition I am trying to put a rule to colour it green when successful and red when not.


Screenshot 2022-11-18 at 17.03.04.png


So the final result is I am looking for a card where if the file is successful to get the text in green and if not then the text should be in red.

Thanks.

1 ACCEPTED SOLUTION

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:

vyueyunzhmsft_0-1669079616590.jpeg

 

 

(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:

vyueyunzhmsft_1-1669079616590.jpeg

 

vyueyunzhmsft_2-1669079616591.jpeg

 

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

vyueyunzhmsft_3-1669079616591.jpeg

 

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

 

View solution in original post

4 REPLIES 4
v-yueyunzh-msft
Community Support
Community Support

Hi , @SS_1122 

According to your description, you want to " based on the above condition I am trying to put a rule to colour it green when successful and red when not.". Right?

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

vyueyunzhmsft_0-1668994635223.png

(2)If your want to chow color in your table , you can click "New Measure" to crrate a measure:

Measure = var _date = MAX('Table'[Date])
var _sum =SUMX( FILTER('Table','Table'[Date] = _date) , [Delivered]+[Submitted])
return
IF(_sum=2,"green", "red")

(3)Then you can configure it to the field you want:

vyueyunzhmsft_1-1668994847484.png

 

if you want to show the whole row color , you can configure it to the all fields in your visual:

vyueyunzhmsft_2-1668994885628.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.

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

DateSubmitted Delivered
10/10/202211
11/10/202211
12/10/202211
13/10/202211
14/10/202211
15/10/202210
16/10/202210
17/10/202200
18/10/202200
19/10/202201
20/10/202201
21/10/202201
22/10/202211
23/10/202210
24/10/202210
25/10/202211
26/10/202211
27/10/202211
28/10/202211
29/10/202211
30/10/202211
31/10/202211
01/11/202210
02/11/202210
03/11/202211
04/11/202201
05/11/202211
06/11/202201
07/11/202201
08/11/202211
09/11/202211

 

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

DateSubmitted DeliveredSuccessful 
10/10/202211File Submission is successful 
11/10/202211File Submission is successful 
12/10/202211File Submission is successful 
13/10/202211File Submission is successful 
14/10/202211File Submission is successful 
15/10/202210File Submission is not successful 
16/10/202210File Submission is not successful 
17/10/202200File Submission is not successful 
18/10/202200File Submission is not successful 
19/10/202201File Submission is not successful 
20/10/202201File Submission is not successful 
21/10/202201File Submission is not successful 
22/10/202211File Submission is successful 
23/10/202210File Submission is not successful 
24/10/202210File Submission is not successful 
25/10/202211File Submission is successful 
26/10/202211File Submission is successful 
27/10/202211File Submission is successful 
28/10/202211File Submission is successful 
29/10/202211File Submission is successful 
30/10/202211File Submission is successful 
31/10/202211File Submission is successful 
01/11/202210File Submission is not successful 
02/11/202210File Submission is not successful 
03/11/202211File Submission is successful 
04/11/202201File Submission is not successful 
05/11/202211File Submission is successful 
06/11/202201File Submission is not successful 
07/11/202201File Submission is not successful 
08/11/202211File Submission is  successful 
09/11/202211File 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.

Screenshot 2022-11-21 at 11.11.32.png

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:

vyueyunzhmsft_0-1669079616590.jpeg

 

 

(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:

vyueyunzhmsft_1-1669079616590.jpeg

 

vyueyunzhmsft_2-1669079616591.jpeg

 

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

vyueyunzhmsft_3-1669079616591.jpeg

 

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

 

lbendlin
Super User
Super User

Please provide sanitized sample data that fully covers your issue.
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...
Please show the expected outcome based on the sample data you provided.

https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.