Hi, I am trying to calculate a value using a formulae field and the SUBSET function.
My table contains data regarding time bought and time spent by customers.
What I need is a field that calculates the difference between time bought and time spent per customer.
I tried to use the SUBSET_SUM funtion as follows:
IF([Type]= "Bought", (SUBSET_SUM([Time], (SUBSET([Customer]), (SUBSET([Type], "Bought")))))), 0)
It returns an error about the comma after subset ([customer]). Can you please help? Am I doing something wrong?
The SUBSET page on Visokio.com is quite good, but I can't find a description for the situation where I have two variables in my subset (Customer & Type), but for only one I have a value (Type = Bought).
Here's an English equivalent to the formula to answer that question:
When calculating the field X for a given record Y,
find all records
where Customer = [the value of the Customer field for record Y]
and Type = "Bought"
and take the Sum of the Time field for those records.
In this sentence, "Customer" appears twice, for the same reason as in the formula.
Hi Steve, I have tried the subset functions a lot since our discussion above and it really helps me.
I have used your example, but now I need the SUBSET3 function and I notice that I can't figure out the logic behind the formulae.
The Function Guide tells me that the SUBSET2 function works as follows: SUBSET2([Month],[Client],"February","Acme Bank")
This example assumes the two variables being fixed values; February and Acme Bank. In case one of the two variables is flexible, your example works as follows:
SUBSET2([Client], [Month], [Client], "February").
My question is still: Why must the field [Client] be mentioned twice in this function? What if the client was known and the month is flexible? Would it be as follows: SUBSET2([Month], [Client], [Month], "CLIENT_XYZ")?
SUBSET3 on the Function guide is explained as: SUBSET3([Month],[Client],[Country], "February","Acme Bank","UK"). Again, assuming alle variable being known.
My dataset needs: SUBSET3([Client],[Month],[ProductCategory],"February", "Sugar" ). This returns only NULL and I am not sure how to set up this function and also understand the logic.
Arjan- You need to mirror the order of the fields and the subset values explicitly, like this: SUBSET3([Client],[Month],[ProductCategory],[Client],"February", "Sugar" ). meaning take subsets with all different values for 'Client', the [Month]=February, and the [Product Category]=Sugar.