How to change name row using expresssion in SSRS report? - tsql
I had generated a report .In one of columns i need to change the names of rows in that column.
In first row
clumnA clumnB
Value 78
grade 85
But i need to change in report to get output like.I need to rename value and grade
clumnA clumnb
Number 78
Percent 78
Note i dont want make any changes in Stored Proc
Note:To get value i am using expression below
=Microsoft.VisualBasic.Interaction.IIF(Fields!Rating.Value = 3, Fields!Measurement.Value, Nothing)
My Answer is
=Microsoft.VisualBasic.Interaction.IIF(Fields!Rating.Value = 3, "Number", Nothing)
You can do this sort of thing with the SWITCH function:
=SWITCH(Fields!Rating.Value = 3, "Number", Fields!Rating.Value = 4, "Percent", True, Fields!ColumnA.Value)
Note that I am using True at the end of the SWITCH function to simulate Else - that is, if none of the previous conditions hold, the value for True will be returned, so we get whatever is in ColumnA except when Rating is 3 or 4.
Related
Sum in range until value change
I'am trying to use this formula to make it work =ARRAYFORMULA(IF(ISDATE_STRICT(S2:S) ; (MATCH(MAX(AB2:AB),AB2:AB;0)-1) ; "" )) If there is a date in Column "S" I want it to display the sum of the blanks that would appear if in Column "S" is text =ARRAYFORMULA(IF(ISDATE_STRICT(S2:S) ; ArrayFormula(MATCH(FALSE ; ISBLANK(AB2:AB) ; 0)-1) ; "" )) I've tried this one as well but I only get 0's as a result. Any idea how I can make it work? Here is the sample sheet. https://docs.google.com/spreadsheets/d/19f5phXeAwXwrKbWz7njgbznmurOav72GUuo_5IGcbls/edit?usp=sharing
in Q2 use: =ARRAYFORMULA(IF(ISBLANK( I1:INDEX(I:I; ROWS(I:I)-1)); {N2:INDEX(N:N; ROWS(N:N))\ I1:INDEX(N:N; ROWS(N:N)-1)}; I1:INDEX(O:O; ROWS(O:O)-1))) in X2 use: =INDEX(LAMBDA(x; IFNA(VLOOKUP(x; QUERY(VLOOKUP(ROW(x); IF(ISDATE_STRICT(x); {ROW(x)\x}); 2; 1); "select Col1,count(Col1) group by Col1"); 2; 0)-1)) (Q2:INDEX(Q:Q; MAX((Q:Q<>"")*ROW(Q:Q))))) UPDATE: we start with column Q. we can take a range Q2:Q but that range contains a lot of empty rows. the next best thing is to check the last non-empty row and set it as the end of the range resulting in Q2:Q73. but static 73 won't do in case the dataset would grow or shrink so to get 73 dynamically we take the MAX of multiplication of Q:Q not being empty and row number of that case eg. Q:Q<>"" will output only TRUE or FALSE so what we are getting is ... TRUE * 72 = 1 * 72 = 72 TRUE * 73 = 1 * 73 = 73 FALSE * 74 = 0 * 74 = 0 ... so the formula for getting Q2:Q73 is: =Q2:INDEX(Q:Q; MAX((Q:Q<>"")*ROW(Q:Q))) it could also be: =INDEX(INDIRECT("Q2:Q"&MAX((Q:Q<>"")*ROW(Q:Q)))) but it's just long to type... next, we use the new LAMBDA function that allows us to reference cell/range/formula with a placeholder. simple LAMBDA syntax is: =LAMBDA(x; x)(A1) where x is A1 and we can do whatever we want with the 2nd (x) argument of LAMBDA like for example: =LAMBDA(a, a+a*120-a/a)(A1) you can think of it as: LAMBDA(A1, A1+A1*120-A1/A1)(A1) or as just: =A1+A1*120-A1/A1 the issue here is that we repeat A1 4 times but with LAMBDA we do it only once. also, imagine if we would have 100 characters long formula instead of A1 so the final formula with lambda would be 300 characters shorter compared to "old way" formula. back to our formula... x is the representation of Q2:Q73. now let's focus on VLOOKUP. basically, the idea here is that IF Q column contains a date we return that date, otherwise we return the last date from above. simply put: =ARRAYFORMULA(VLOOKUP(ROW(Q2:Q73); IF(ISDATE_STRICT(Q2:Q73); {ROW(Q2:Q73)\Q2:Q73}); 2; 1)) as you can see Y2, Y3 and Y4 are the same so all we need to do is to count them up and later take away one to exclude Q2 but include just Q3 and Q4 eg. 3-1=2. for that we use simple QUERY where the output is: date count 30.06.2022 3 so all we need to do is to pair up dates from Q column to QUERY output for that we use the outer VLOOKUP where the output is as follows: 3 #N/A #N/A 9 #N/A #N/A ... now is the right time for that -1 correction while we have these errors coz ERROR-1=ERROR and 3-1=2 so after this -1 correction the output is: 2 #N/A #N/A 8 #N/A #N/A ... and all we need to do now is to hide errors with IFERROR and the output is column X
If the hour is >=19 or <=8 then return a value "OOH" if its not within that range return "OPEN"
I have the formula =IF(AND(HOUR(D2)<=8,HOUR(D2)>=19), "OPEN", "OOH") This should return the required text values "OPEN" or "OOH" depending if the hour falls within the noted range. When trying in cell E2 of this sheet https://docs.google.com/spreadsheets/d/1xNFVHLnQGkRgZdLmejCyU0BByOPBY8NMoIYj6SkTFGY/edit#gid=431567503 it returns a text value but not always the correct one. What could be missing from this formula? I have also tried swapping the range around without success =IF(AND(HOUR(D2)>=19),HOUR(D2)<=8, "OPEN", "OOH") Update: also tried with OR instead of AND but it does no better =IF(OR(HOUR(C3) >=19, HOUR(C3) <=8), "OPEN", "OOH")
if from 8 to 19 = OPEN then use this in E2: =INDEX(IF((HOUR(C2:C)>=8)*(HOUR(C2:C)<19), "OPEN", "OOH"))
Your conditions are a bit wrong. The IF form is: =IF(condition, value_if_true, value_if_false) In your question, you say hour >=19 OR hour <= 8, so you should be using OR, as you do in your update. However, you switched the true and false values in your updated statement. Try: =IF(OR(HOUR(C3) >=19, HOUR(C3) <=8), "OOH", "OPEN") With 8:01, this returns "OOH" With 9:01, this returns "OPEN" With 18:01, this returns "OPEN" With 19:01, this returns "OOH"
Logic error. The thing can't be <=8 and >=19 at the same time. If you reverse the signs to >8 and <19, you might get closer to what you want.
How to display total sum values in summary band of groups partial sums
I have a report like the image below: Note that the sections separated by a blank space are grouped by the month and are iterated over a group band. I want to put partial in the summary band by the type of the register, like in the example figure get the sum for Register type A in January = 10, February = 5, March = 1 so as the total = 10 + 5 + 1 = 16. So the summary will look like: How can I achieve that kind of conditional sum in jasper? Thanks in advance.
After trying a little bit with iReport I found a solution: to get the partial sum by type you have to add a variable that has the calculation type as "sum" and the reset type set as "Report". Once you set the values you have to create a variable Expression that has value only when the cell value of type is the desired value, so for the example in the question, in the column Value of the summary band in cell with the value "16" you have the expression : $F{type}.equals("A") ? $F{value} : 0 and so on for the other types in the summary.
Select a number of random rows based on one columan condition in matlab
I have a table 'X' like this: name value score joy 3 60 rony 8 50 macheis 20 20 joung 2 80 joy 8 3 joy 90 0 joung 4 78 machies 3 23 joy 7 99 I want to select 2 random rows(with name, value, score) where the name is 'joy'. I applied something like this: mnew = datasample(find(X.name=='joy'),2); but it does not work! and gives me the error: Undefined operator '==' for input arguments of type 'cell'. The rows should be selected randomly (with all columns values) where the name is joy. Does anyone any other solution of this problem? how can i do it in MATLAB?
You have the right idea, but in order to check for the presence of a string within a cell array of strings, you need to use strcmp, ismember, or another method for comparing a string to a cell array. You probably also want to specify that you don't want to use replacement when calling datasample so you don't get the same row twice. subx = X(datasample(find(strcmp(X.name, 'joy')), 2, 'Replace', false),:);
MS Access 2010 Form Box Control Source IIF Statement
I am running into the Max Character Issue when trying to put my IIF statement into a box I have created for the calculation of a score on my form. The box code is: =IIf([cbov1]="na" And [cbov2]="na" And [cbov3]="na" And [cbov4]="na" And [cbov5]="na" And [cboV6]="na" And [cboV7]="na" And [cboV8]="na" And [cboV9]="na" And [cboV10]="na" And [cboV11]="na" And [cboV12]="na" And [cboV13]="na" And [cboi1]="na" And [cboi2]="na" And [cboi3]="na" And [cboi4]="na" And [cbop1]="na" And [cbop2]="na" And [cbop3]="na" And [cbop4]="na" And [cbop5]="na" And [cbop6]="na" And [cbop7]="na" And [cbop8]="na" And [cbop9]="na" And [cbop10]="na" And [cbop11]="na" And [cbof1]="na" And [cbof2]="na" And [cbof3]="na" And [cbof4]="na" And [cbof5]="na" And [cbof6]="na" And [cbof7]="na" And [cbof8]="na" And [cbof9]="na" And [cbof10]="na" And [cbom1]="na" And [cbom2]="na" And [cbom3]="na" And [cbom4]="na" And [cbom5]="na" And [cbom7]="na" And [cbom8]="na" And [cbom9]="na" And [cbom10]="na" And [cbom6]="na",0,(IIf([cboV1]="yes",0,0)+IIf([cbov2]="yes",0,0)+IIf([cbov3]="yes",0,0)+IIf([cbov4]="yes",0,0)+IIf([cbov5]="yes",0,0)+IIf([cboV6]="yes",0,0)+ IIf([cboV7]="yes",0,0)+ IIf([cboV8]="yes",0,0)+ IIf([cboV9]="yes",0,0)+ IIf([cboV10]="yes",0,0)+ IIf([cboV11]="yes",0,0)+ IIf([cboV12]="yes",0,0)+ IIf([cboV13]="yes",0,0)+IIf([cboi1]="yes",5,0)+IIf([cboi2]="yes",3,0)+IIf([cboi3]="yes",3,0)+ IIf([cboi4]="yes",4,0)+IIf([cbop1]="yes",5,0)+IIf([cbop2]="yes",5,0)+IIf([cbop3]="yes",5,0)+IIf([cbop4]="yes",5,0)+ IIf([cbop5]="yes",5,0)+ IIf([cbop6]="yes",4,0)+ IIf([cbop7]="yes",4,0)+ IIf([cbop8]="yes",4,0)+ IIf([cbop9]="yes",4,0)+ IIf([cbop10]="yes",2,0)+IIf([cbop11]="yes",2,0)+IIf([cbof1]="yes",1,0)+IIf([cbof2]="yes",1,0)+IIf([cbof3]="yes",1,0)+IIf([cbof4]="yes",1,0)+ IIf([cbof5]="yes",1,0)+ IIf([cbof6]="yes",1,0)+ IIf([cbof10]="yes",0,0)+ IIf([cbof7]="yes",3,0)+ IIf([cbof8]="yes",3,0)+ IIf([cbof9]="yes",3,0)+IIf([cbom1]="yes",5,0)+IIf([cbom2]="yes",1,0)+IIf([cbom3]="yes",1,0)+IIf([cbom4]="yes",1,0)+IIf([cbom5]="yes",1,0)+IIf([cbom6]="yes",1,0) +IIf([cbom7]="yes",3,0) +IIf([cbom8]="yes",2,0) +IIf([cbom9]="yes",5,0) +IIf([cbom10]="yes",5,0))/(IIf([cboV1]="na",0,0)+IIf([cbov2]="na",0,0)+IIf([cbov3]="na",0,0)+IIf([cbov4]="na",0,0)+IIf([cbov5]="na",0,0)+IIf([cboV6]="na",0,0)+ IIf([cboV7]="na",0,0)+ IIf([cboV8]="na",0,0)+ IIf([cboV9]="na",0,0)+ IIf([cboV10]="na",0,0)+ IIf([cboV11]="na",0,0)+ IIf([cboV12]="na",0,0)+ IIf([cboV13]="na",0,0)+IIf([cboi1]="na",0,5)+IIf([cboi2]="na",0,3)+IIf([cboi3]="na",0,3)+ IIf([cboi4]="na",0,4)+IIf([cbop1]="na",0,5)+IIf([cbop2]="na",0,5)+IIf([cbop3]="na",0,5)+IIf([cbop4]="na",0,5)+ IIf([cbop5]="na",0,5)+ IIf([cbop6]="na",0,4)+ IIf([cbop7]="na",0,4)+ IIf([cbop8]="na",0,4)+ IIf([cbop9]="na",0,4)+ IIf([cbop10]="na",0,2)+ IIf([cbop11]="na",0,2)+IIf([cbof1]="na",0,1)+IIf([cbof2]="na",0,1)+IIf([cbof3]="na",0,1)+IIf([cbof4]="na",0,1)+ +IIf([cbof5]="na",0,1)+ +IIf([cbof6]="na",0,1)+ +IIf([cbof7]="na",0,3)+ +IIf([cbof8]="na",0,3)+ +IIf([cbof9]="na",0,3)+ +IIf([cbof10]="na",0,0)+IIf([cbom1]="na",0,5)+IIf([cbom2]="na",0,1)+IIf([cbom3]="na",0,1)+IIf([cbom4]="na",0,1)+IIf([cbom5]="na",0,1)+IIf([cbom6]="na",0,1) +IIf([cbom7]="na",0,3) +IIf([cbom8]="na",0,2) +IIf([cbom9]="na",0,5) +IIf([cbom10]="na",0,5)))*(IIf([cbov1]="no" Or [cbov2]="no" Or [cbov3]="no" Or [cbov4]="no" Or [cbov5]="no" Or [cboV6]="no" Or [cboV7]="no" Or [cboV8]="no" Or [cboV9]="no" Or [cboV10]="no" Or [cboV11]="no" Or [cboV12]="no" Or [cboV13]="no",0,1)) The purpose of the score is to score "Yes" with points, Score "No" as no points, and then have "NA" remove from the overall score. So if a person has 67 out of 67 points, they get a 100. The maximum points is 100 if all questions are answered "Yes" or "No". I need to have all portions of the calculation because CBOV1-13 have a stipulation of if they are "No" the score is automatically 0%. I don't know of a work around for the MAX CHARACTER you get within the expression builder on the Control Source box via the properties sheet. Any help on a work around for this issue or ways to make the code shorten and fit with the same end result would be a huge help.
First, I would be tempted to have my field as a numeric (0,1,2 instead of "na,Yes,No" Then you could use addition...IIF{cvb01 + Cvb02 +cvb03 = 0, 0 ,...else Using Strings I can think of two ways. One in the formula using concatenation (ugly) IIF[cvb01] & [cvb02] & [cvb03] = "NANANA", 0 , ...Else) I would be more tempted to write a function to take care of it. dim NAcount as integer Dim YesCount as integer Dim NoCount as integer dim ctr as integer dim StrAns as string for ctr = 1 to 10 StrAns = Fields ("cvb" & Ctr) Select case StrAns Case "NA" NaCount = NACount + 1 '...add values here Case "Yes" '...more values go here Case "No" '... more values End Select Next Ctr ...