# App Development

Announcements
NEW webinar Dec. 7th: 2023 Outlook, A Pivotal Year for Data Integration SIGN ME UP!
cancel
Showing results for
Did you mean:
Partner - Contributor III

## Calculate dimension

Hello!

My colleague has a problem with which I could not help him. Suppose we have a table:

 user_id country atr1 atr2 1 RU 1 66 2 US 1 55 3 RU 1 55 3 RU 2 77 2 US 2 88

He want to count how many times user_id occurs in table (name it "#frequency"), and after that use the result of it and use like dimention and calculate how many user_id occurs in what #frequency.

Result must be somting like this:

 #frequency #users 1 1 2 2

The problem is: if we select atr1 = 1, the result will be like

 #frequency #users 1 3

So, i cant calculate it in script, because dimention #frequency will change when in choose something.

Maybe I don't see simple solution?

Labels (1)
• ### Calculate dimension

1 Solution

Accepted Solutions

@lord_zeus  if you select atr1 = 1 normaly what is the expected output ?

for me 3 is correct !

in dimension :

``=aggr(count(user_id),user_id)``

Expression:

``=count(distinct user_id)``

output:

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
4 Replies
Partner - Master III

hi
short one ,
for dimension use this

``class(aggr(count(user_id),user_id),1)``

expression:

``count(distinct user_id)``

@lord_zeus  if you select atr1 = 1 normaly what is the expected output ?

for me 3 is correct !

in dimension :

``=aggr(count(user_id),user_id)``

Expression:

``=count(distinct user_id)``

output:

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
Partner - Contributor III
Author

Guys, thanks! Both answers are correct, but for my task, Taoufiq_Zarra will give the most correct answear.

Tags
Community Browser