Forum Discussion
Calculating appearances in a column conditioned to values from another column
- 9 years ago
I finally solved it in a way I don't like so much... but it works:
First, I created a new table "Entries_user_week" to calculate the amount of days every user entry to the system. For every week (1 to 53) I created manually a column (sample with week 2):
2 = calculate(count(Table1[WeekDay]);filter(Table1;Table1[UserID]='Entries_user_week'[UserID]);filter(Table1;Table1[Week]=2))
Then I created another table calculating the total amount of users with entries 1 day, 2 days,... 7 days for every week (a column per week, manually defined):
02 = calculate(count(Entries_user_week[2]);filter(Entries_user_week;Entries_user_week[2]=Users_NDays_week[Days per Week]))
I'm sure this is not the best way to get that result. I would like to know how to avoid the manual creation of 53 colums in each table. :)
Best,
Juan
- 9 years ago
Hi again,As I supose, it was much easier i had done it before.
The question can be solved without creating any another table o measure. It just needs some data preparing work with Query Editor:
1.- We need to duplicate Date column and Transform it to get Week number. I named it [WeekID]
2.- We need to remove duplicates because many users have several entrances per day. So I solved it creating a new column witch concatenate UserID-Date. Then we can use 'Remove Duplicates' on that column.
3.- Finally, we can Group [UserID] and [WeekID] by UserID counting rows of WeekID. This action will give us a table with three columns: [UserID], [WeekID] and [DaysPerWeek].
With this Table we can use Matrix Visualization tool: [DaysPerWeek] as Rows, [WeekID] as Columns and [UserID] (count) as values.
That's all. Much more simple than I did before.
I finally solved it in a way I don't like so much... but it works:
First, I created a new table "Entries_user_week" to calculate the amount of days every user entry to the system. For every week (1 to 53) I created manually a column (sample with week 2):
2 = calculate(count(Table1[WeekDay]);filter(Table1;Table1[UserID]='Entries_user_week'[UserID]);filter(Table1;Table1[Week]=2))
Then I created another table calculating the total amount of users with entries 1 day, 2 days,... 7 days for every week (a column per week, manually defined):
02 = calculate(count(Entries_user_week[2]);filter(Entries_user_week;Entries_user_week[2]=Users_NDays_week[Days per Week]))
I'm sure this is not the best way to get that result. I would like to know how to avoid the manual creation of 53 colums in each table. :)
Best,
Juan