Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I have a row data table with that indicates login per user in each month,
i also in the load script calculated 4 additional columns (W1 , W2, W3, W4) to indicate in which week on the month the login was made.
now i wounder what is the best approach OR what is do able and how:
1. should i flat the table so instead of having 4 rows for user that logged in each week of the month i will have a single row?
if so how to i do that in the load script in the simplest way?
2. Can i just count the user with a condition in set analysis?
here is what i have, and i added in paint the lines (counts) that i want to do in the line chart
hope my question is clear 🙂
Yes to both questions.
You should easily be able to do this in script:
Load UserID, Month, Field1, Field2, Count(W1) as W1, Count(W2) as W2, Count(W3) as W3, Count(W4) as W4
From YourTable
GROUP BY UserID, Month, FIeld1, FIeld2;
If you prefer, you can do a simple user count per week even if it's four rows rather than one row. Just count(W1)+Count(W2)+Count(W3)+Count(W4).
If you pre-calculated these in the script, you should just be able to check them. If you didn't fully pre-calculate (that is, you didn't check the "only" aspect, just the yes/no for each one individually), you should be able to do this in set analysis with the '-' operator (Exclusion - first but not the other). I can't test this as I don't have your data but the code should look something like this:
Count(DISTINCT {< W1 ={1} , W2 -= {1}, W3 -= {1}, W4 -= {1} >)
Here's a Henric post about this aspect of set analysis that shows a couple of other approaches and explains the differences:
https://community.qlik.com/t5/Qlik-Design-Blog/Excluding-values-in-Set-Analysis/ba-p/1471704