How to use index match when you have 2 values? - indexing

I have a list with 300 names codes and each of these names have more than 1 value, e.g.,
CODE - VALUE
300 - 1
300 - 2
300 - 3
400 - 1
400 - 2
For each code, I want to return the greatest value, and after that I want to transform this greatest value into his name, e.g.,
CODE - VALUE - NAME
300 - 1 - alpha
300 - 2 - beta
300 - 3 - gamma
400 - 1 - theta
400 - 2 - sigma
So for code “300” I want to return “gamma” and for code “400” I want to return “sigma”.
Any thoughts?
Regards

place the following formula in F1 and the code you are looking for in E1. This assumes your second table is located in A1:C5. Adjust ranges to suit your data. Avoid full column references within the aggregrate function.
=INDEX(C:C,AGGREGATE(14,6,ROW(A1:A5)/((A1:A5=E1)*(B1:B5=AGGREGATE(14,6,B1:B5/(A1:A5=E1),1))),1))

Related

Conditional formatting in webi Rich Client 4.1 of multiple values

I'm in BO 4.1 using a crosstab table. It is summary data based off specific detail information. Example:
Area-Days Late-Order #-Reason
1 - 5 - 12345-Lost
1 - 2 - 843254 - Lost
2 - 4 - 7532384 - Lost
1 - 7 - 12353 - Not home
So the output would be
Area 1 Area 2
Lost 2 1
Not home 1 0
Now for the conditional formatting part, I want it to highlight the Area 1 Lost cell as red because two of the orders are greater than 3 days late.
For whatever reason it seems to not be doing it because it's getting hung up line item 2 because that one is less than 3 days late.
Thank you!
I cheated and created a new object and then summed and did an if statement. Thanks for looking at this.

Calculate percentage between two values

I have two columns that hold numbers for which I am trying to calculate the difference in % between and show the result in another column but the results seem to be wrong.
This is the code in question.
SELECT
GenPar.ParameterValue AS ClaimType,
COUNT(Submitted.ClaimNumber) AS SubmittedClaims,
COUNT(ApprovalProvision.ClaimNumber) AS ApprovedClaims,
COUNT(Declined.ClaimNumber) AS DeclinedClaims,
COUNT(Pending.ClaimNumber) AS PendingClaims,
ISNULL(SUM(SubmittedSum.SumInsured),0) AS TotalSubmittedSumInsured,
ISNULL(SUM(ApprovedSum.SumInsured),0) AS TotalApprovedSumInsured,
ISNULL(SUM(RejectedSum.SumInsured),0) AS TotalRejectedSumInsured,
ISNULL(SUM(PendingSum.SumInsured),0) AS TotalPendingSumInsured,
--This column is to show the diff in %
CASE WHEN COUNT(Submitted.ClaimNumber) <> 0 AND COUNT(ApprovalProvision.ClaimNumber) <> 0
THEN (COUNT(ApprovalProvision.ClaimNumber),0) - (COUNT(Submitted.ClaimNumber),0)
/COUNT(Submitted.ClaimNumber) * 100
ELSE 0
END
What I need is to show the difference in % between the columns SubmittedClaims and ApprovedClaims. Any column, or both may contain zeroes and it may not.
So it's: COUNT(Submitted.ClaimNumber) - COUNT(ApprovalProvision.ClaimNumber) / COUNT(Submitted.ClaimNumber) * 100 as far as I know.
I have tried this and an example of what it does is it takes 1 and 117 and returns 17 when the difference between 1 and 117 is a decrease of 99.15%. Another example is 2 and 100. This simply returns 0 whereas the difference is a decrease of 98%.
CASE WHEN COUNT(Submitted.ClaimNumber) <> 0 AND COUNT(ApprovalProvision.ClaimNumber) <> 0
THEN (COUNT(ApprovalProvision.ClaimNumber),0) - (COUNT(Submitted.ClaimNumber),0)
/COUNT(Submitted.ClaimNumber) * 100
ELSE 0
END
I've checked this link and this seems to be what I am doing.
Percentage difference between two values
I've also tried this code:
NULLIF(COUNT(Submitted.ClaimNumber),0) - NULLIF(COUNT(ApprovalProvision.ClaimNumber),0)
/ NULLIF(COUNT(Submitted.ClaimNumber),0) * 100
and this takes for example 2 and 100 and returns -4998 when the real difference is a decrease of 98%.
For completion, Submitted.ClaimNumber is this portion of code:
LEFT OUTER JOIN (SELECT * FROM Company.Schema.ClaimMain WHERE CurrentStatus=10)Submitted
ON Submitted.ClaimNumber = ClaimMain.ClaimNumber
ApprovalProvision.ClaimNumber is this:
LEFT OUTER JOIN (SELECT * FROM Company.Schema.ClaimMain WHERE CurrentStatus=15)ApprovalProvision
ON ApprovalProvision.ClaimNumber = ClaimMain.ClaimNumber
Ideally, this column would also deal with 0's. So if one value is 0 and the other is X, the result should return 0 since a percentage can't be calculated if original number is 0. If the original value is X and the new value is 0, I should show a decrease of 100%.
This will occur across all columns but there is no need to flood the page with the rest of the columns since all calculations will occur in the same manner.
Anybody see what I'm doing wrong?
I'm not familiar with why you have (x,0) as a syntax
But I see that you have
(COUNT(ApprovalProvision.ClaimNumber),0) - (COUNT(Submitted.ClaimNumber),0)
/COUNT(Submitted.ClaimNumber) * 100
shouldn't it be,
( COUNT(ApprovalProvision.ClaimNumber) - COUNT(Submitted.ClaimNumber) )
/COUNT(Submitted.ClaimNumber) * 100
It looks like it would do count of ApprovalProvision.ClaimNumber - 100 since submitted.claimnumber divided by itself is 1 times 100 is 100.
The 4900 number actually sounds right. Lets take the following example, you have 2 apples, and then you're given 98 more and got 100 apples.
An increase of 98% would have meant from 2 apples, you would have 3.96 apples.
An increase of 100% means from 2 apples you end with 4 apples. An increase of 1000% means from 2 apples you end with 22 apples. So 4000% means you end with 82 apples. 5000% means from 2 apples, you reach 102 apples.
(100-2)/2*100 = 98 / 2 = 49 * 100 = 4900, so it looks like there is a 4900% increase in number of apples if you started with 2 apples and reach 100.
Now if you had flipped the 2 and 100, say starting with 100, now you have 2,
(2-100)/100*100 = -98, so a -98% change of apples, or a 98% decrease.
Hope this solves your problem.

SSRS comparing Current Row to Previous Row

I have the following Expression in a field in SSRS:
=iif(Fields!Score.Value > Previous(Fields!Score.Value),"Greater","Less Than")
I have the following Scores in my scenario across 4 rows:
3
3
4
5
It results in:
3 - Greater
3 - Less Than
4 - Greater
5 - Greater
The issue is with the first row always being Greater. It should be blank because there isn't a previous row to compare against. I would expect the results to be as follows:
3 -
3 - Same
4 - Greater
5 - Greater
How could I change the above formula to produce the above result?
The above is an example of only one row group. There are then further row groups with different Scores, so the different results of Same/Greater/Less Than need to work across the different row groups.
Try following:
=IIF(RowNumber(NOTHING)=1,"",IIF(Fields!Score.Value = Previous(Fields!Score.Value),"Same",IIF(Fields!Score.Value > Previous(Fields!Score.Value),"Greater","Less Than")))
modified. try now.

Compare Values in Excel in all sheets that have the same title/name

Hello fellow netizens of the programming community!
Need some help with a couple of excel worksheets that I'll be working forth day in and out.
Here's a some info of what I have on hand, and what I want to do..
I have several worksheets (10 of them) of similar (not 100% identical) tables ..
one worksheet may look like this (x, y and z are other unimportant variables)
name - score - x - y - z
jon - 50 - x - y - z
sam - 50 - x - y - z
pad - 50 - x - y - z
fed - 50 - x - y - z
mum - 50 - x - y - z
and another worksheet may look like this
name - score - x - y - z
pad - 50 - x - y - z
mum - 50 - x - y - z
fed - 50 - x - y - z
jon - 50 - x - y - z
sam - 50 - x - y - z
simply put, there are names such as 'jon' and the relevant scores that can occur across all the worksheets, or names such as 'ped' that can only appear once in one worksheet.
I would like to compare all the sheets at the same time, finding out the highest score for jon, sam, pad, fed, mum across all the sheets and have these information presented in another new sheet itself.
for e.g.
the new sheet should present data as
name - highest score
jon - 39
sam - 22
pad - 42
mum - 22
I hope whatever I'm trying to say is not confusing anyone! If anyone could help, ill greatly appreciate it!
The solution is available via pivot table formed across multiple sheets.
Steps:
Assuming your files is open, and you are in one of your sheets.
Alt+D+P (Opens a dialog box)
Select "Multiple consolidation ranges" and "Pivottable" >>Next
Select "Create a single page field for me" >>Next
Here, select in the Range box and Add, all the table areas one by one. Have one addition per sheet of yours. So you should have 10 ranges getting inserted here. >>Finish
You will get a pivot table where the Values field will have "Count of score" (it is mostly this, else it could be Sum of score, etc. Here's how you change it to max) Click on whatever is in the values field >> Value Field Settings >> Max >> Ok.
(If you want to choose min/average/count/product/stdDev, this is the place to make that change)
As a caveat, do check fields in Filters/Columns/Rows are as you want. I have run a sample pivot on the two tables you have provided, screenshot is attached, this is how the table should look like.
Sample Pivot screenshot on data provided

change specific data of column

I have a table in which 10 record, now i want to update specific column data, means some part some column data and some not, for example in row 1 i want to change std with standard and other data will remain same, change same thing in all row in a single query. can it will be possible? and remember we cant remove and add cell again because it will change id
id - col1 - col2
1 - A - std abcad
2 - B - std bcddsad
3 - C - std avadsad
4 - A - std abcdsad
5 - B - std bcddsa
6 - C - std avadsad
7 - A - std abcdsd
8 - B - std bcddsds
9 - C - std avadsd
You can use the replace function for this
Update
table
Set
col2 = Replace(col2, 'std', 'standard');
UPDATE tblName
SET Column .WRITE('Standard',(CHARINDEX('std',Column,1)-1),LEN('std'))