Yoel Kortick Senior Librarian How to use the CASE condition to change text in an Alma Analytics report Yoel Kortick Senior Librarian
Agenda Introduction Example on textual values Example on numerical values
Introduction There may be cases where the actual text appearing in a report would be more appropriate as a different text. In other words, the text in a report appears as the data appears in Alma. However, to make the report “meaningful” it may be that certain strings of text should change to specific values. This may done by using the CASE parameter After the text is changed by CASE parameter the report may be grouped and totaled on the new text
Introduction First possible need for CASE: For example perhaps we have a report of all items in certain library and how many times they were loaned It may not really be important to see the exact number of times an item was loaned. Rather, a text such as “Less than 5 times” or “Between 5 and 10 times” or “More than ten times” may be more useful. We could then make a CASE to change the values.
Introduction Second possible need for CASE: Another example may be that we have a report of all items ordered from a certain vendor and how many days they arrived late (after the expected arrival date) Again, it may not really be important to see the exact number of days the items was late. Rather, a text such as “Less than 5 days” or “Between 5 and 10 days” or “More than ten days” may be more useful. We could then make a CASE to change the values.
Introduction Third possible need for CASE: Another example may be that we have a report of the number of loans per user group at each circulation desk It may not really be important to see the exact name of the circulation desk Rather, a text such as “Resource Sharing Desk” or “Regular Circ. Desk” may be more useful. We could make a CASE changing any desk which is not “Resource Sharing Desk” to “Regular Circ. Desk”
Introduction Fourth possible need for CASE: Another example may be that we still have the report of the number of loans per user group at each circulation desk It may not really be important to see the exact name of the user group Rather, a text such as “Staff” or “Student” may be more useful. We could make a CASE changing all groups which are some type of Staff to “Staff” and any group which is some type of student to “Student”
Agenda Introduction Example on textual values Example on numerical values
Example on textual values Here we have a report of number of loans by circulation desk and user group. We have one Resource Sharing Desk, two reading rooms, and several other libraries. We want to Leave “Resource Sharing Desk” as is Change “Reading Room 1” and “Reading Room 2” to “Reading Room” Change all others to “Standard Circulation Desk”
Example on textual values Note: If you copy and paste any values from here the apostrophes should be rewritten manually or error messages will occur Rewrite manually the “ and the ‘
Example on textual values Here is the report before using “CASE”
Example on textual values The field we want to change is "Loan Circulation Desk"."Circ Desk Name“ Therefore the CASE string will start with: CASE "Loan Circulation Desk"."Circ Desk Name" Then we will add the condition WHEN CASE "Loan Circulation Desk"."Circ Desk Name“ WHEN
Example on textual values And now with the actual conditions we want. If it is a textual field it needs a single quote. If it is a numerical field it does not need quotes. Start with something basic which will change ‘Reading Room 1’ to ‘Reading Room’ and everything else to ‘Standard Circulation Desk’ Put the formula under the column “Circ Desk Name’ by doing “edit formula”
Example on textual values CASE "Loan Circulation Desk"."Circ Desk Name” WHEN ‘Reading Room 1’ THEN ‘Reading Room’ ELSE ‘Standard Circulation Desk’ END
Example on textual values Now we have it working, and will begin to make the CASE also include ‘Reading Room 2’ and ‘Resource Sharing Desk’ CASE "Loan Circulation Desk"."Circ Desk Name" WHEN 'Reading Room 1' THEN 'Reading Room' WHEN 'Reading Room 2' THEN 'Reading Room' WHEN 'Resource Sharing Desk' THEN 'Resource Sharing Desk' ELSE 'Standard Circulation Desk' END
Example on textual values Now it appears as follows: We need to make this column narrower and give it a more relevant name
Example on textual values We will rename the column
Example on textual values We will rename the column
Example on textual values Here are the results
Example on textual values Before (without CASE) After (with CASE)
Agenda Introduction Example on textual values Example on numerical values
Example on numerical values Now we will make a CASE on the number of Loans We will group the loans into groups of 1-10, 10-20, 20-30, etc. The formula is: CASE WHEN "Loan"."Loans" >= 1 AND "Loan"."Loans" <= 10 THEN '1-10' WHEN "Loan"."Loans" >= 11 AND "Loan"."Loans" <= 20 THEN '11-20' WHEN "Loan"."Loans" >= 21 AND "Loan"."Loans" <= 30 THEN '20-30' WHEN "Loan"."Loans" >= 31 AND "Loan"."Loans" <= 40 THEN '30-40' WHEN "Loan"."Loans" >= 41 AND "Loan"."Loans" <= 50 THEN '41-50' WHEN "Loan"."Loans" >= 51 AND "Loan"."Loans" <= 60 THEN '51-60' WHEN "Loan"."Loans" >= 61 AND "Loan"."Loans" <= 70 THEN '61-70' ELSE 70+' END
Example on numerical values Here it is after doing “Edit Formula on the field “Loans”
Example on numerical values Here are the results
Example on numerical values Before (without CASE) After (with CASE)
THANK YOU! xxxx.xxxx@exlibrisgroup.com Check out public segmentations 27 27