Forum Discussion

cliu822's avatar
cliu822
New Member
3 years ago
Solved

Count value before reaching a certain value for a funnel chart

Hi everyone,

 

I am trying to create a funnel chart for 10 steps of a process. The funnel chart should show how many users have completed each of these 10 steps.

I have an example table "Step Table" for the 10 steps as follows:

Name of StepDescription of StepLevel of Step
Step 1Stopped at Step 11
Step 2Stopped at Step 22
Step 3Stopped at Step 33
Step 4Stopped at Step 44
Step 5Stopped at Step 55
Step 6Success at Step 66
Step 7Success at Step 77
Step 8Success at Step 88
Step 9Success at Step 99
Step 10Success at Step 1010

 

There is another table called "User Table". In this table, the column "Steps" contains all the steps for each user, "Value" contains the information if a user complete the step or not. However, the value 0 or 1 serves as "No" and "Yes", so for the first 5 steps containing "Stopped" in the description, a 0 means this user didn't stop at this step. For the other 5 steps containing "success" in the description, the value 1 means he did succed at this step.

An example "User Table" can be found as follows:

Date UIDStepsValue
2022-01-0212345Step 20
2022-01-0212345Step 30
2022-01-0212345Step 50
2022-01-0212345Step 41
2022-01-0212345Step 10
2022-01-0212345Step 60
2022-01-0212345Step 80
2022-01-0212345Step 70
2022-01-0212345Step 90
2022-01-0212345Step 100
2022-03-0467890Step 10
2022-03-0467890Step 40
2022-03-0467890Step 50
2022-03-0467890Step 71
2022-03-0467890Step 30
2022-03-0467890Step 20
2022-03-0467890Step 61
2022-03-0467890Step 81
2022-03-0467890Step 9 0
2022-03-0467890Step 100

 

In this example, User 12345 stopped at Step 4 while user 67890 stopped at Step 9. So For Step 1-3 there are 2 users completed these steps. For Step 1 user has completed it, for step 5-8 1 user has completed them, for step 9-10 nobody has completed it.

The trick here is, for step 1-5, when a user stopped at step 4 (value = 1), the value for his step 5 will still be 0, because he didn't stop at step 5 (He didn't even start it!), because of this tricky part, I don't know how to write metric for this funnel chart. I will really appreciate any answer!

 

Thanks!

  • Create a new column in the user table:

     

    Max Completed Step =
    var current_user = FactUsers[UID]
    var max_step = CALCULATE(MAXX(VALUES(FactUsers[UID]),MAX(FactUsers[Steps])),ALL(FactUsers),FactUsers[UID]=current_user,FactUsers[Value]=1)
    var step_level = LOOKUPVALUE(dim_steps[Level of Step],dim_steps[Name of Step],max_step)
    var previous_step_level = step_level-1
    return IF(step_level <= 5, previous_step_level,step_level)
     
    This column holds an information about max completed step by it's user. It's also has a logic for steps 1-5 to reduce the steps for rows with 1.
     
    Then create a measure:
     
    Number of users =
    var current_step = MAX(dim_steps[Level of Step])
    return CALCULATE(DISTINCTCOUNT(FactUsers[UID]),FactUsers[Max Completed Step] >= current_step)
     
    Result:

     

3 Replies

  • bolfri's avatar
    bolfri
    Solution Sage

    Create a new column in the user table:

     

    Max Completed Step =
    var current_user = FactUsers[UID]
    var max_step = CALCULATE(MAXX(VALUES(FactUsers[UID]),MAX(FactUsers[Steps])),ALL(FactUsers),FactUsers[UID]=current_user,FactUsers[Value]=1)
    var step_level = LOOKUPVALUE(dim_steps[Level of Step],dim_steps[Name of Step],max_step)
    var previous_step_level = step_level-1
    return IF(step_level <= 5, previous_step_level,step_level)
     
    This column holds an information about max completed step by it's user. It's also has a logic for steps 1-5 to reduce the steps for rows with 1.
     
    Then create a measure:
     
    Number of users =
    var current_step = MAX(dim_steps[Level of Step])
    return CALCULATE(DISTINCTCOUNT(FactUsers[UID]),FactUsers[Max Completed Step] >= current_step)
     
    Result:

     

  • bolfri 

    Thank you so much for the reply. There is just a small problem, that the "Steps" i.e. "Name of Step" are more complicated than that. It is actually more like below:

    Name of StepsStep DescriptionLevel of Step
    StoppedbgdfsStopped at bgdfs1
    StoppedhgjkgStopped at hgjkg2
    StoppedahaghStopped at ahagh3

     

    In this way, how can I adjust the variable max_step? Because MAX() can not find the maximum step anymore if the name is actually some randome words.

     

    Thank you very much again!

    • cliu822's avatar
      cliu822
      New Member

      I have figured this out, in the fact table I added a column which convert the name of steps to "Step 1,2,3 etc.", and then use MAX() on this column. Thank you so much for your answer, it works fine now!