Find Average from "count if" and "count total" in Expression
I'm trying to find the percent of inventory coverage. I have a table showing each department on the rows. My goal is to have a column that displays the percentage covered, but Qlik's expression syntax is trippy and is messing me up.
If the Inventory is equal to or greater than the Requirement for that product number, it is considered covered. The percent covered column expression should only consider an item covered if its Inventory is greater than the Requirement, otherwise it is not covered at all.
Here is an example of what the end table should look like:
Count of Products
To hopefully showcase the logic I'm wanting to achieve, this is a table of the Product Number, Inventory, and Requirement of a department that has 4 products:
In this example, the percent covered column for this department would be 25%, because only one product number met the criteria for being covered (third row).
To get this logic, I've kept on an `if` statement to be `If(Inventory > Requirement, 1, 0)`so that if it's covered it's 1, and if not it's 0. All my logic has focused around this concept within an average formula, but in different syntaxs.