简体   繁体   中英

DataStudio ::: Count_Distinct Calculation based on two values

I have a data set with two values. The first being User ID, the second being Type.

I previously had a count_distinct on the user ID. However, if a user changes their Type, the metrics we have to show 'Type' of user shows two instances of that once unique user.

I would like some SQL which basically states if the User ID and Type Match, then count that as a unique user. If either one of those change, count that also as a unique user. So that..

1) Jane Doe - Support User
2) Jane Doe - Employee User
3) John Smith - Support User

This would show as 3 unique users, rather than 2 based on a count_unique on just the User ID.

One way to accomplish this is with a calculated field that looks something like the following:

COUNT_DISTINCT(CONCAT(USER_ID, ' - ', TYPE))

You might need to replace USER_ID and TYPE with your field names.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM