How can I count only unique occurrences of a value from a table using multiple criteria?

I'm trying to calculate the percentage of users for each role (admin, mod, general user, etc.) who are logged in in a specific timeframe (1 month, 3 months, 6 months, 1 year). Editing the datasheet I'm leaving is not an option, as this spreadsheet should be self-calculating (if that makes sense). Right now I only want numbers because calculating% should be simple.

I am using columns like id, eventTime, ScreenName and userGroup.

For example, I want to count how many users from userGroup "admin" have signed up in the last month. Using ScreenName because it is unique and uniform because ya .. The data I pull from records, time, username, user group and page name for every page the user has viewed on the website, so the user can have multiple records on the same day.

The code I have written so far:

=SUMPRODUCT(((data!$B:$B>(TODAY()-30))*(data!$B:$B<=TODAY()))*(data!$G:$G=G$1))

      

'data' is the sheet I am trying to count against.

Here are some pseudocode to help:

SUMPRODUCT((eventTime>30 days ago)*(evenTime<todays date))*(userGroup = referenced userGroup))

      

If I need to log in as an administrator and then view seven pages on the website, the data will contain seven different rows that store the page / time / myusername / myrole data. The equation above counts every single instance when my username appears, not how many users are logged in. I want it to return "1" because only one user signed up this month even though they were viewing multiple pages. But the equation returns "7".

TL: DR I'm trying to list the number of active users over a period of time. My formula was for one month. But all I need is just one unique screenName / every screen.

Example of what the data looks like that I'm pulling from

+3


source to share


1 answer


If you have a list of all Screen names (just once, with a name ScreenNamesList

), then the easiest way to do it is something like this: if the ScreenNames are in column A:

=SUMPRODUCT((COUNTIFS(data!$B:$B,">"&TODAY()-30,data!$B:$B,"<="&TODAY(),data!$G:$G,G$1,data!$A:$A,ScreenNamesList)>0)+0)

.... but if you don't have such a list, you can use this formula - the range of notes is reduced, whole columns will be very slow:



=SUM(IF(FREQUENCY(IF(data!$B$2:$B$1000>TODAY()-30,IF(data!$B$2:$B$1000<=TODAY(),IF(data!$G$2:$G$1000=G$1,MATCH(data!$A$2:$A$1000,data!$A$2:$A$1000,0)))),ROW(data!$A$2:$A$1000)-ROW(data!$A$2)+1),1))

Formula

must be confirmed with CTRL+ SHIFT+ENTER

+2


source







All Articles