Visokio website     Downloads     Video tutorials     KnowledgeBase  
SUBSET function - Visokio Forums
SUBSET function
  •     Mees November 27, 2009 12:39PM
    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).

    I have attached an example iok.

    Thanks, Arjan
    Attachments
    Hours spent.iok 4K
  • 5 Comments
  •     steve November 27, 2009 1:56PM
    Here's an updated file with the formulas you need, commented. Requires 2.5+
    Attachments
    Hours spent2.iok 5K
  •     Mees November 27, 2009 2:12PM
    Steve, thanks so much. This is great.

    One question though about your formula:
    Why is it necessary to have the Customer field twice in the SUBSET2 function?

    Thanks, Arjan
  •     steve November 30, 2009 8:32AM
    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.
  •     Mees February 15, 2010 2:21PM
    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.

    Hope you can help
    Thanks
  •     tjbate February 15, 2010 2:53PM
    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.

Welcome!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In Apply for Membership