Determine when a cell is blank - if-statement

At work, I needed that if the value of a cell is equal to the cell next to it, then the background color changes to red, but it is doing it for blank cells, so it may be confusing for others.
Is there a way to avoid blank cells?
I have this formula:
=IF($D2=$C2,TRUE)
then background color changes to red (not sure if the correct formula, but it worked at the beginning, I am doing this in the Conditional Format Rules in Google Sheets).

I used this:
=IF($D1=$C1,IF(ISBLANK($D1),FALSE,TRUE))
I set the range to be C1:D1000. Your formula was putting the formatted color on the row above the data being checked. This formula checks if they are equal. Then if so it checks if one is blank. You don't have to check if they are both blank, the formula already knows that they are equal. So then if they are equal, return false, otherwise return true.

Clear formatting from C2 to wherever in ColumnD suits and with that selected then Format - Conditional formatting..., Custom formula is and:
=($C2=$D2)*($C2<>"")
Then select formatting of choice and Done.

Related

Power BI: How to change the background color for specific rows in a matrix?

I want to change the background color for specific rows in a matrix based on the name of the row.
Here is my matrix
What I did so far was to create a conditional column X in the data table that says, for example, when asset_name is A82 give me 1, in all other cases give me 0. Then for each field in Values, I created a conditional rule based on that X column -
when column X is 1 - blue color, when is 0 - white color. Basically, I apply conditional background color for the columns. However, I want to be able to conditionally color the rows. There is no option to choose a background color for the fields in Rows. Therefore, I'm able to custom-color only the column part of the matrix.
Is there any workaround for this?
Could you use something like this - you can conditionally format a row based on the value of a measure https://www.cloudfronts.com/conditional-formatting-by-row-in-a-matrix/

Matrix Conditional formatting : why when column has 0 then its all red? Power BI

I set up Color Scale no color from lowest value to red color for highest value.
But if I filter data and column "Losses" have values $0 then for some reason the whole column becomes red.
Is any way how can it make it with "No color" if all the values are 0's?
in order to fix the problem I also have to indicate max value. So I used maximum value as $1,000,000 which is fit for my dataset.

RRD Graph - Change line colour by value

I have a RRD database with data:
"DS:pkts_transmitted:GAUGE:120:0:U",
"DS:pkts_received:GAUGE:120:0:U",
"DS:pkts_lost:GAUGE:120:0:U",
"DS:rtt_min:GAUGE:120:0:U",
"DS:rtt_avg:GAUGE:120:0:U",
"DS:rtt_max:GAUGE:120:0:U",
And I want that the Avg line change colour if I lose any package.
For example, if I lose 5 packets make the line blue, if I lose 10 make it red.
I see people doing it but I read the documentation and I can't find how to do this.
The way to do this is to actually have multiple lines defined (one of each colour) and hide the ones you don't want to see at any time, using calculations.
For example, say we have an RRD with two DSs:
DS:x:GAUGE:60:0:U
DS:y:GAUGE:60:0:1
Now, we want to show the line for x in red if y is 0, and blue if it is 1. To do this, we create two calculated values, x1 and x2.
CDEF:x1=y,0,EQ,x,UNKN,IF
CDEF:x2=y,1,EQ,x,UNKN,IF
Thus, x1 is active if y=0 and x2 if y=1. Yes, this could be simplified, but I'm showing it like this for the example.
Now, we can make lines using these:
LINE:x1#ff0000:MyLine
LINE:x2#0000ff
Note that the second line doesn't need a legend. Now, the line will appear to change colour depending on the value of the y metric, since at any time the other line will be UNKN and therefore not displayed.
You can extend this, of course, to have multiple colours and more complex thresholds.

Pyplot rotated labels offset by one

Just getting into matplot lib and running into odd problem - I'm trying to plot 10 items, and use their names on the x-axis. I followed this suggestion and it worked great, except that my label names are long and they were all scrunched up. So I found that you can rotate labels, and got the following:
plt.plot([x for x in range(len(df.columns))], df[df.columns[0]], 'ro',)
plt.xticks(range(10), df.columns, rotation=45)
The labels all seem to be off by a tick ("Arthrobacter" should be aligned with 0). So I thought my indexing was wrong, and tried a bunch of other crap to fix it, but it turns out it's just odd (at least to me) behavior of the rotation. If I do rotation='vertical', I get what I want:
I see now that the center of the labels are clearly aligned with the ticks, but I expected that they'd terminate on the ticks. Like this (done in photoshop):
Is there a way to get this done automatically?
The labels are not "off", labels are actually placed via their "center". In your second image, the corresponding tick is above the center of the label, not above its endpoint. You can change that by adding ha='right' which modifies the horizontal alignement of the label.
plt.plot([x for x in range(len(df.columns))], df[df.columns[0]], 'ro',)
plt.xticks(range(10), df.columns, rotation=45, ha='right')
See the comparison below :
1)
plt.plot(np.arange(4), np.arange(4))
plt.xticks(np.arange(4), ['veryverylongname']*4, rotation=45)
plt.tight_layout()
2)
plt.plot(np.arange(4), np.arange(4))
plt.xticks(np.arange(4), ['veryverylongname']*4, rotation=45, ha='right')
plt.tight_layout()

Google Charts - Change the Order of Lines drawn

I have the following array that I wish to turn into a Google line chart:
array = [
['Period 12', '165', '183'],
['Period 11', '145', '133'],
['Period 10', '125', '143'],
...
]
The 1st column represents the label on the x-axis, the 2nd is the value for the current period and the 3rd is the value for the last period.
I am using formatters for the number values so that they show a prefix ($ or £).
I push each row into Google's TableData, I set the current trend line to be bright blue and the previous one a faded blue. This is the result:
As you can see, the previous trend line is drawn 'over' the current one. I was wondering is it possible to 'flip' the order in which they're drawn?
I've tried pushing the values of the 3rd column first and then the 2nd column AND flipping the colors of the trend lines. But in that case the popups on the points show the wrong periods (light blue becomes current period and light blue - previous period) like so:
I've check and double checked this approach, but it doesn't seem to work.
Any help is appreciated!
PS: Sorry for the links, reputation doesn't allow posting images directly.
Don't know if you solved the problem, but I had a similar problem with the ordering. In my case having a pointSize added to the options was the problem, eventho I changed the order of the columns. Removing the pointSize solved the problem.