Expression to Highlight certain Cells depending on the Date - devexpress

I need to highlight a cell in the Customer Rate column based on that it is 1 week past a delivery date. I have already created a variable for the style - xrControlStyle2 with the color it needs to be.
Iif(AddDays([delivereddt], 7),[xrControlStyle2],[thirdparty_cost])
The result I get is that the Customer Rate column which is thirdParty_cost is blank.

Right click on the textbox Text Box Properties > Fill > Fill Color and write the following expression:
=IIF(Today() > DateAdd("ww", 1, CDate(Fields!DeliveryDate)), "Red", "Green")

In DevExpress the expression is
Iif(Now() > AddDays(DeliveryDate,7), 'red', 'green')

Related

Link the order of a vector to another vector r

I have two vectors of character values with the same size.
The first one is always the same four HEX color codes, while the second one is always the same four countries.
The only difference is that the countries may change order.
So for example I have ("Blue", "Red", "Yellow", "Green"), always in the same order.
While the second one can vary, and it could be for example ("Spain","Italy","Germany","Japan") or it could be ("Italy","Japan", "Germany",Spain")
However, I want the colors to be always associated with the same country.
What I though about was reordering the hex code colors based on the order of the countries.
So Spain would be #1 and then blue would be #1.
If Spain changes places to, let's say #3 then blue would become #3.
I tried with
colors[match(colors, countries)]
But it's not working.

Lighter color in datagrid alternate row color

I have a datagrid where I use a color theme to set the row hilite color:
set the dgprop["hilite color"] of group "dg_xxx" to color1 -- #dc8400
Now I would like to have the alternate row color based on color1 but with a lighter note (i.E. 30% lightened up is #FFD14D).
Is there a way to do something like the following with RGB or HEX calculations to make it dynamically changing when color1 changes?
set the dgprop["alternate row color"] of group "dg_xxx" to (color1 - 30%)
The following function returns a shade, which is calculated by adding a share s of the remaining distance to white. Warning 1: basically you increase the brightness by using this function and you may end up with an ugly type of grey and eventually white. Warning 2: s and -s don't give exactly reverse results.
function rgbShade
if the paramCount is 4 then
put param(1) into r
put param(2) into g
put param(3) into b
put param(4) into s
else
put item 1 of param(1) into r
put item 2 of param(1) into g
put item 3 of param(1) into b
put param(2) into s
end if
put r+(255-r)*s into r
put g+(255-g)*s into g
put b+(255-b)*s into b
return r,g,b
end rgbShade
Usage:
get rgbShade("123,45,67",0.2) // increase of 20% of remaining distance
put rgbShade(123,45,67,0.2) into myShade // same as above
Example:
set the dgprop["hilite color"] of group "dg_xxx" to color1 -- #dc8400
set the dgprop["alternate row color"] of group "dg_xxx" to rgbShade(color1,.3)

Filtering grouped data in R

I was wondering if anyone can help with grouping the data below as I'm trying to use the subset function to filter out volumes below a certain threshold but given that the data represents groups of objects, this creates the problem of removing certain items that should be kept.
In Column F ( and I) you can see Blue, Red, and Yellow Objects. Each represent three separate colored probes on one DNA strand. Odd numbered or non-numbered Blue ,Red, and Yellow are paired with a homologous strand represented by an even numbered Blue, Red, and Yellow. Ie data in rows 2,3,and 4 are one "group" and pair with the "group" shown in rows 5,6,and 7. This then repeats, so 8,9,10 are a new group and that group pairs with the one in 11,12,13.
What I would like to do is subset the groups so that only those below a certain Distance to Midpoint (column M) are kept. The Midpoint here is the midpoint of the line that connects the blue of one group with the blue of its partner, so the subset should only apply to the Blue distance to midpoint, and that is where I'm having a problem. For instance if I ask to keep blue distances to midpoint that are less than 3, then the objects in row 3 and 4 should be kept because they are part of the group with the blue distance below 3. Right now though when I filter with the subset function I lose Red Selection and Yellow Selection. I'm confident there is a straighforward solution to this in R, but I'd also be open to some type of filtering in excel if anyone has suggestions via that route instead.
EDIT
I managed to work something out in Excel last night after posting the question. Solution isn't pretty but it works well enough. I just added a new column next to "distance to midpoint" that gives all the objects in one group the same distance so that when I filter the data I won't lose any objects that I shouldn't. If it helps anyone in the future, the formula I used in excel was:
=SQRT ( ((INDEX($B$2:$B$945,1+QUOTIENT(ROWS(B$2:B2)-1,3)*3))- (INDEX($O$2:$O$945,1+QUOTIENT(ROWS(O$2:O2)-1,3)*3)) ) ^2 +( (INDEX($C$2:$C$945,1+QUOTIENT(ROWS(C$2:C2)-1,3)*3))-(INDEX($P$2:$P$945,1+QUOTIENT(ROWS(P$2:P2)-1,3)*3)) ) ^2 +( (INDEX($D$2:$D$945,1+QUOTIENT(ROWS(D$2:D2)-1,3)*3))-(INDEX($Q$2:$Q$945,1+QUOTIENT(ROWS(Q$2:Q2)-1,3)*3)) ) ^2)
Would be easier with a reproducible example, but here's a (hacky) plyr solution:
filterframe<-function(df,threshold){
df$grouper<-rep(seq(from=1,to=6),nrow(df)/6)
dataout<-df%>%group_by(grouper)%>%summarise(keep=.[[1]]$distance_to_midpoint<threshold)
dataout[dataout$keep,]
}
filterframe(mydata)
A base R solution provided below. The idea is that once your data are in R, you (edit) keep! rows iff they meet 2 criteria. First, the Surpass column has to contain the word "blue" in it, which is done with the grepl function. Second, the distance must below a certain threshold (set arbitrarily by thresh.
fakeData=data.frame(Surpass=c('blue', 'red', 'green', 'blue'),
distance=c(1,2,5,3), num=c(90,10,9,4))
#thresh is your distance threshold
thresh = 2
fakeDataNoBlue = fakeData[which(grepl('blue', fakeData$Surpass)
& fakeData$distance < thresh),]
There's probably also a quick dplyr solution using filter, but I haven't fully explored the functionality there. Also, I may be a bit confused on if you also want to keep the other colors. If so, that's the same as saying you want to remove the blue ones exceeding a certain distance threshold, which you would just do a -which command, and turn the < operator into a > operator.

SQLite ORDER BY Without Special Ordering

If I have a column in a SQLite table like "Color" with values like "Red," "Blue," and "Green" and use ORDER BY Color, it'll automatically order the colors alphabetically.
Is there any way to specify the order of the colors? For instance, if I specified:
ORDER BY Color ('Green', 'Red', 'Blue')
to get the results ordered so the rows with Green are first, followed by the ones with Red are second, and so on?
For example, if I have this table:
Car Color
----------- ----
Mustang Red
Thunderbird Blue
DeLorean Blue
380SL Green
If I do a normal "SELECT Car FROM AntiqueCars ORDER BY Color," it would return:
Thunderbird
DeLorean
380SL
Mustang
(Although Thunderbird and DeLorean might end up swapped.)
I'd like to be able to use "SELECT Car FROM AntiqueCars ORDER BY Color(Red, Green, Blue)," and get:
Mustang
380SL
Thunderbird
DeLorean
Is there any way to do this kind of sorting with values that are normally not recognized as alphabetically or numerically (or temporally) sortable?
You can use CASE in your ORDER BY clause to specify custom ordering:
SELECT Car
FROM AntiqueCars
ORDER BY CASE WHEN Color = 'red' THEN 1 WHEN Color = 'green' THEN 2 ELSE 3 END

Show quantity and percent values on Chart

I everyone;
I'm working with a ASP NET Chart and I have one Column Chart. In this chart I want to show the values of percent and quantity like '10% (100)'.
I did it and it's working, but the column is shown based on percent value but I want to base it on quantity value.
This is my code:
Series mainSeries = new Series(serieName);
mainSeries.XValueMember = "ANSWER";
mainSeries.YValueMembers = "Total";
mainSeries.Label = "#PERCENT" + "\n(#VALY)";
This is the problem. I want that the size of the column is shown based in percent value and in this way the column size is based on quantity value.
If I change the YValueMembers by "Percent" when I have quantity equal 100 and percent equal 10, the value is shown like '10% (10)', I mean...just the percent value is shown.
That is my chart, I would like to show the column based in 50% not in 1 (quantity).
Any idea about how can I do it?
I am not sure, but this can help
Chart.Series[0].Points.DataBind(dv, "PKProject", "TotalSale", "LegendText=ProjectLabel");
ChartSalesPerProject.Series[0].Label = "#PERCENT{P0}";

Resources