Part 6 of the Exago Video Training Series
(This video is applicable for versions prior to v2017.2. Click here for the latest version.)
Welcome back to the Exago Video Training Series! Today we’ll be exploring formulas which allow us to modify a given cell’s contents. We’re currently looking at a report displaying product sales grouped by their order number.
The ‘discontinued’ field will display a 1 if a product is discontinued, and a 0 otherwise. That might not be clear to someone who needs to review this report output, so let’s select the cell under the discontinued header, then open our formula editor by clicking the F of X icon.
The formula editor gives access to data fields on the left pane, and on the right we can see various categories of functions. Functions will take a specified number of input values, and give back a new value based off the input. In this case, let’s open our logical category, and select the ‘if’ function. Notice we’re provided with a description of the function here to let us know what input it needs, as well as what the function will output. Our ‘if’ function needs three inputs. The first is a condition that must become either true or false - in this case, we’ll check if our ‘discontinued’ field is equal to 1. If our first condition is true - if our discontinued field is equal to 1 - our cell will show the second input. So if the product has been discontinued, let’s output a simple ‘yes’. Since our output is static text, we’ll need to surround it with quotes like so. Finally, our third input will be displayed if the first condition is false. So if the product hasn’t been discontinued, we’ll output ‘no’, again wrapped in quotes.
Now that our if() function is completed, hitting okay will exit the formula editor. We can see the cell text we just modified now has an equal sign here to denote it is a formula.
For each product sale we’ll generate some revenue, however to see the final revenue per product, we need to subtract any discount we provide from the revenue per product. We’ll go into our formula editor here add the revenue field, and then subtract the discount field with the subtraction operator like so.
Next let’s add a count of the number of products per order, and the final revenue summed per order as well. We’ll highlight an available cell in our group footer on order number, open our formula editor, and dig into the aggregate category. I’ll add the aggcount function, and call it on my product name field. Because we’re in a group footer on order number, this will count the number of products per order. Hitting okay, we can now use another cell in our group footer to add an aggsum function. We want to sum the final revenue, which is revenue minus discount. We’ve already calculated final revenue per product in cell D6. Navigating into our formula editor, we can add our aggsum, and reference the revenue cell in our formula using a capital D and a 6, surrounded by square brackets. This cell will now show us the total revenue per order.
We’ve got a product count and revenue sum for each order, but we might want to see those values across the entire report as well. Holding control, I can click and drag to copy both my aggcount and aggsum formulas down to my report footer. Formulas know what section they’re being called from. This means the aggcount/sum in our group footer will get order totals, while the aggcount/sum in the report footer will get report wide totals, despite the two sets of formulas being identical.
We can add each customer’s name and title so we know who each order is going to. I’ll highlight this cell and open my formula editor, and add the contact name field. Next I’d like to concatenate the contact name with contact title, and include a comma in between. The & acts as a concatenate operator and will combine whatever is directly to the left with whatever is directly to the right, so I’ll add an &, and then a comma in quotes as its static text. I can then add another &, and now I’ll add my contact title field. This formula will now display the contact name, a comma, and then the contact title.
Finally let’s add the month of each order to the header on order number. We’ll go into our formula editor, and dig into our date functions category. We’ll first add the month function, which gives the month number given an input date. We’ll give the function the order date field. We can now hit okay, and execute our report.
Looking at the output, we can see the order month displayed in the top right of each order. For each product in an order, we can see whether or not that product has been discontinued, and the final revenue after subtracting the discount. We can see the number of products and total revenue per order, the customer contact and title, and the overall total products and revenue at the bottom of our report.
This concludes our discussion on formulas. Be sure to check out our segments on charting and crosstabs, and as always, Happy Reporting!