Case Else Statement from different tables - object

I am trying to retrieve a name based on a certain type of claim. Would seem easy enough, but it's not working for me. I am working with 2 main tables, claim and exposure, and a contactname table. Each claim can have multiple exposures, but each exposure can have only one claim. Both tables contain a nameID field - claim.nameID and exposure.nameID. The nameID correlates to ContactName table.
Contact Name
ID Name
111 Jim
222 Bob
333 John
444 Sam
555 Walt
Normally, each claim can have multiple exposures and the exposures on a claim can have the same name or different names. The name ids are found on the exposure.
The exposure.nameID joins ContactName.ID
Claim claim.nameID ExposureNo exposure.nameID Name
A null 1 111 Jim
A null 2 222 Bob
A null 3 333 John
B null 1 444 Sam
B null 2 444 Sam
Workers comp claims are different. Each workers comp claim can have multiple exposures, but all the exposures have the same name. Since the exposures on a claim have the same name, the name ids are found, not on the exposure table, but the claim table. Go figure… The claim.nameID joins ContactName.ID AS ClaimContactName.
Claim claim.nameID ExposureNo exposure.nameID Name
C 111 1 null Jim
C 111 2 null Jim
C 111 3 null Jim
D 555 1 null Walt
D 555 2 null Walt
I can get the names for non workers comp claims and can get the names for workers comp claims. However, when I put the 2 queries together, I don’t get any results.
Select
CASE WHEN #Select(Claim\Policy Type) = 'Workers'' Compensation' THEN
CASE WHEN ClaimContact.Name IS NULL AND ClaimContact.Name.FirstName IS NULL THEN ClaimContact.LastName
WHEN ClaimContact.Name IS NOT NULL THEN ClaimContact.Name
ELSE ClaimContact.FirstName + Space(1) + ClaimContact.LastName END
ELSE
CASE WHEN Contact.Name IS NULL AND Contact.FirstName IS NULL THEN Contact.LastName
WHEN Contact.Name IS NOT NULL THEN Contact.Name
ELSE Contact.FirstName + Space(1) + Contact.LastName END
END
Haven’t done much of this, but could really use the help to figure this out. Thank you in advance.

This was for an SAP Universe using Information Design Tool. I ended up creating a derived table that gave me exactly what I needed, including learning something new along the way.

Related

Excel formula count after certain observation in c horological order

I am having tough time building a logic around this problem for a while , Hope some one can help.
I have 3 column of data. Lets call them Customer ID , Call ID , Agent ID
Customer ID and Agent ID can have repetition however Call ID is unique .
Now i have a table with these columns- they are stacked in chronological order based on date or time. Also one customer can call multiple time to multiple agent generating unique caller ID every time.
Here i want to count number of time one customer has called after certain agent ID has received the call. So count or freq function will have to have a rule embedded in chronological function or "Count after certain rule has been met"
Below is the table
CusID CalID Agent
1 123 a
1 22 b
1 112 a
1 222 a
1 54 a
1 334 a
2 221 a
2 312 b
2 334 b
2 129 b
2 986 a
4 98 b
In above table i want to calculate number of observation for customer id '1'after he has called to agent 'b' so the answer will be 4. I have used couple of unique count based no multiple crietria using combination of sumif 1/countif however major problem is counting after certain observation.
can any one help
You can use this formula that will change the range to count to match where b is found the first time.
=COUNTIF(INDEX(A:A,AGGREGATE(15,6,ROW($C$2:$C$13)/(($C$2:$C$13=E3)*($A$2:$A$13=E2)),1)+1):$A$13,E2)

Multiple Vlookup for identifying a customers name or business

I want to create a multiple vlookup to match records on an ID from two sheets. If the column reference does not exist I want it to look at a different column.
This is what I have already:
=IF(VLOOKUP(A2,'Roots data'!F$2:Y$1139,18,0)>0,VLOOKUP(A2,'Roots data'!
F$2:Y$1139,17,0))
18 being the column which I want to check first and 17 being the column I want to check second. Can you please advise why this is not working appropriately?
Sample data:
Table 1:
ID First Name Last Name Age/Road
1 James John
2 John Miller
Table 2:
ID Age Address
1 21 1 Road
2 22 2 Road
In this example, if I wanted to find the Age of ID 1 which is James I would do a vlookup to identify this, if the age was not present I instead would want to know the address for ID 1, to be populated under Age/Road in Table 1.
I believe this is what you are looking for:
=IF((VLOOKUP(A2,'Roots data'!F$2:Y$1139,18,FALSE)=0),VLOOKUP(A2,'Roots data'!F$2:Y$1139,17,FALSE), VLOOKUP(A2,'Roots data'!F$2:Y$1139,18,FALSE))

How to format a table in an Excel macro?

I am trying to format a table from one format to another utilizing a macro. Please see below for an example of what I am trying to do.
From this:
User_ID FNAME LNAME ROLE_ID
1 Bob Smith Role1
1 Bob Smith Role2
1 Bob Smith Role2.2
To this
User_ID FNAME LNAME ROLE_ID ROLE_ID2
1 Bob Smith Role1 Role2, Role2.2
So I have 5 different "role categories". For example, A, B, C, D are my categories. Each category can have multiple roles assigned to a user. I want to have 5 static columns that list the different role categories and what the user is assigned from each.
If this is possible, it would be helpful to understand where to start.

pivot table in excel dynamic coumn titles

I have data in the following form
userID course groupNumber
===========================
111 A 90
111 B 89
234 A 90
234 B 99
234 C 67
I want to convert it to the following form for using it in other program that require it in the following form
userID course1 group1 course2 group2 course3 group3
============================================================
111 A 90 B 89
234 A 90 B 99 c 67
I am not sure if I can do it using pivot table since I do not know how to label the header of columns as course1 group1 ...and I do not know for sure number of courses and groups but I can estimate it if needed.
can I do this in Ecxel ? please direct me since I am not sure what I should search for in google, is this dynamic pivot table?
I am trying also to do it in sql but I still searching it
Note sorry I could not kwno how to format it properly
thanks
There is a very easy answer: you should keep the table as is, and use an excel pivot table in the following way:
Columns: GroupNumber
Rows: UserID, Course
Values: COUNT(GroupNumber)

Index/match with two criteria anyway to get the second set of data using unique identifiers?

I've been stuck for some time trying to match up two different data spread sheets. I'm trying to match off dollar amounts with matching names that correspond to the dollar amount. I went ahead and assigned unique identifiers to each row thinking that would help me match off the amounts, but my problem comes when there are two or more dollar amounts that are the same and have the same name.. is there anyway to get the second id to show up?
Formula sheet: (I need The second 112 to pull 113.. anyway thats possible??
A B C D E F G
IDSheett2 IDsheet1 NameSheet1 NameSheet2 Item AmountSheet1 AmountSheet2
554 112 Jim Jim Hat 25 25
555 112 Jim Jim Shoe 25 25
Formula in column B2: it should go through both sheet 1 and 2 and automacially fill in the matching id - id that matches the name and amount.
=IFERROR(INDEX(sheet1!$C$2:$C$1000,MATCH(1,INDEX((sheet1!$A$2:$A$1000=D1)*(sheet1!$B$2:$B$1000=G1),0,1),0)),"")
Data from Sheet2:
A= ID B= Name C= Item Name ( ID basically row 1 = 1, 2 = 2.. )
A B C D
554 Jim Hat 25
555 jim Shoe25
Data from Sheet1:
A= name B= amount C= assigned ID ( ID basically row 1 = 1, 2 = 2.. )
A B C
Jim 25 112
Jim 25 113
I'm also open to other ideas. Thanks for the help.
UPdated::: Based on comments
im not trying to create a database.. i have two sets of data that i'm trying to compare and match off like items(i take matched items and email it out to a group of people). i had to change some of the names because this is work related but the overall concept should remain.
it is Impossible for me to know how many names will be on incoming wires and how many names will be on my expected wires lists. I assigned unique ids per row on each page so i can do iferror/index/match to pull from a unique row to the main page.
What im trying to accomplish:
I have two sets of data: Sheet1 is incoming wires (it gives me a name and an amount) Sheet 2 is the account name, Item its for, and expected amount.
I'm trying to match the name and amount on the formula sheet but i run into the problem of two items with the same name and the same amount only pulling the first ID number it runs into and this becomes a problem because i have another vba code that will delete multiple ID's so i know i'm not counting something twice.
my final page should read:
ID sheet2 IDsheet1 Name Item(sheet2) Amount
554 112 JIM Hat 25
555 113 JIM Shoe 25
but right now the 113 id wont pull and it will just be 112 twice (which will end up getting deleted so i will miss that second match)
..+ everything works perfectly unless there are two items for the same name and the same amount +.. that is the only time i run into this problem.
Is there any code or process that can have the sheet realize that it has already used the ID of 112 once and then automatically fill in the id of 113 (so it won't get deleted by my vba code)?
In your formula sheet, B2 and copied down:
=IFERROR(INDEX(Sheet1!$C$2:$C$1000,MATCH(1,INDEX((Sheet1!$A$2:$A$1000=D2)*(Sheet1!$B$2:$B$1000=G2)*(COUNTIF(B$1:B1,Sheet1!$C$2:$C$1000)=0),),0)),"")

Resources