Rainbow colours to every row in the ssrs report in the same order upto last row - sql-server

How to give Rainbow colours to every 7 rows in the ssrs report in the same order upto last row ?
How to write that expression?
Can anyone help me out.
Thanks in advance

You can do this easily using CHOOSE.
=choose((ROWNUMBER(NOTHING) MOD 7)+1 , "LIGHTBLUE","Yellow", "SILVER","Red", "Green", "Blue", "Orange")
First we get the ROWNUMBER do a MOD 7 (divide it by 7 and find the remainder) . This will give us a number from 0 to 6 so then we add one to this result as CHOOSE is 1 based, then simply supply a list of colours as the choice list.

Related

Google spreadsheet how to count data if contains a value

been trying to solve this but am struggling. Hopefully this is the right place to ask.
What I need to do is search a row for a certain word, say "cat". If that word is found within that row then take the value of another cell ("Gain") in that row and add this to a total. Then what I need to do is take that total, and divide it by the number of times "cat" was found within a group of rows. Is this possible?
Hopefully that explains what I am trying to do.
For example my data looks likething like this -
1 2 3 4 5 Gain
1/6/22 cat bear elephant sheep 7
2/6/22 dog cat mouse cow 12
3/6/33 cat cow horse goat 5
Cow total: 2
Rows containing cow / gain (2/12+5) = 8.5
EDIT: What I have noticed it if I use SUMIF it will work ASLONG as the value I am search for is across a single column. However, if it is spreadout across multiple columns I get a value that isn't correct.
try:
=COUNTIFS(B1:E3, A6)
and then:
=INDEX(SUM(IF(B1:E3=A6, F1:F3, ))/COUNTIFS(B1:E3, A6))
This is the formula I use when I need to count how many cells have specific values in it within a range:
=COUNTif($J56:$J956,"=Cat")

SUMIF for first 5 cells meeting criteria, with moving window

I am looking to find a formula that calculates the cumulative points a team has for its last 5 games (so the first 5 games would have no values) in the last column. So it should return a number between 0 and 15. In the image below you can see an extract of the dataset. The range can also not continue to move down because then for the last 4 games, only the last 4, 3, 2, 1 game points would be added (hope I did not confuse you more).
I have tried to use SUMIF, SUMIFS with relative row numbers in the cell address within a function but sadly, that did not help. I also looked at SUMIF for first 5 cells meeting criteria but that did not make me any wiser.
Link to the full dataset: https://www.dropbox.com/scl/fi/thu7f8ajsz9g8wtfo9q2w/Data.xlsx?dl=0&rlkey=aq8d7xi4zyg7hvkophsrhswpi
Does anyone know how to do this?
FTHG = Full-Time Home Goals
FTAG = Full-Time Away Goals
FTR = Full-Time Result
PH = Points Home
PA = Points Away
Not sure I really get what you want, but I have used two vlookup's to collect PH and PA and add them using a list of unique names from column A.
Here is the formula as text:
=IFERROR(VLOOKUP(J4,$A$4:$H$20,6,0),0)+IFERROR(VLOOKUP(J4,$B$4:$H$20,6,0),0)
Given your original table and assuming that for any particular row, you are interested in the five games above that row (played by the same home team), you can use:
=LET(x,FILTER(G2:$G$2, B2:$B$2=B2),IF(COUNT(x)>=5,SUM(INDEX(x,SEQUENCE(5))),0))
You can see the first NON-ZERO result is in Row 65

Comparing two dates in array based on criteria in Excel

I am trying to find a formula which will compare two dates (Plan 1 minus Plan 2) and determine if they are within ninety days of each other.
The formula I have so far:
{=IF(E1<>"", IF(AND(MIN(IF(C:C=C1, IFERROR(E1-G1, -2), 0))<91, MIN(IF(C:C=C1, IFERROR(E1-G1, -2), 0))>-1), 1, 0), 0)}
The idea is that the array will loop though the Subjects in Column C and for every subject with a non-blank Plan 1 field (Column E), it will loop through the Plan 2 dates in Column G to find the closest one within ninety days. If one exists, the equation will give the Plan 1 a 1.
However, the formula above is not able to handle the dates seen below where there is no exact matching date in Column G.
Thank you for your help.
Scott Craner found the delightful equation below to answer this problem, except for the issue in the image below. It appears to be including a date greater than 90 days (orange highlight).
Use AGGREGATE:
=IF(E2<>"",IFERROR(--(AGGREGATE(15,7,(E2-$G$2:$G$21)/(($C$2:$C$21=C2)*(E2-$G$2:$G$21>=0)),1)<91),0),0)

VBA arrays sorting issues

I am trying to use an array to highlight specific rows in my data.
As shown in the picture, i want to extract the maximum positive profit($) and maximum negative profit($) for each respective serial numbers and highlight it in yellow. For example, Tom123's maximum +ve profit = 100 and -ve profit =-74 , thus both values are highlighted in yellow.
I already know how to highlight cells in vba, but i do not know how to get the rows that i need to highlight. Any help is much appreciated.
Add a column to identify if the column C = max profit or max loss
step 1
In D2, write =IF(OR(C2=MAX(IF((A:A=A2)*(C:C>=0),C:C,"")),C2=MIN(IF((A:A=A2)*(C:C<0),C:C,""))),TRUE,"") then press ctrl+shift+enter.
step 2
drag D2 down.
then you will see:
step 3
highlight A:C if D == true with conditional formatting

Heuristic for shifting array

Given a goal state
int final[3][3]={{1,2,3},
{4,5,6},
{7,8,9}};
and a random initial state, I want to sort my array as final only by shifting rows (right or left) and columns (up and down) of my table
7 8 4 by shifting to the right the first row it will become 4 7 8
2 1 9 2 1 9
6 5 3 6 5 3
So I want to use a* search and I'm trying to find a good heuristic.
I've already tried with misplaced array elements.
Any suggestions?
I view this as an algebraic problem. You are given a group of permutation which is generated by 6 cycles (3 rows and 3 columns) and you want to find some more moves which help you to get to any permutation.
First advice: not all permutations are possible! Since every shift is an even permutation (a 3-cycle is the composition of two transpositions) only even permutations are possible. Hence you will not find any solution to a configuration where all is in place but two swapped numbers as in (2,1,3),(4,5,6),(7,8,9).
Second advice. If r is a row shift and c is a coumn shift, compute the action of rcr'c' where r' and c' are the inverse shifts. This "commutator" is again a cycle of 3 elements but this time they are not in a row or column. By choosing different r and c you get a lot of 3-cycles which can be used in the third advice.
Third advice. Consider the region of numbers which are already in their final position. Apply 3-cycles to the complement of this set to reduce it, until you get to a solution.

Resources