Skip to main content
Question

Native Dashboarss count distinct pairs

  • November 5, 2025
  • 4 replies
  • 45 views

_RT_
Forum|alt.badge.img+3

Hi,

I am trying to create a dashboard and I want one of my chart to be a simple count of the rows of the output table. So, let the generic UDM query be:

events:
  …
match:
  $field1, $field2

Which produces a table with 2 columns. I just want to count the number of rows, but having difficulties in doing so. The solution would be some sort of:

outcome:
  count = count_distinct($field1, $field2)

But the count_distinct() function only accepts a single field as parameter.
Any guidance on achieving the desired outcome? I feel it should be easy and I am missing a simple solution, but I cannot see it.

Thanks,

4 replies

AbdElHafez
Staff
Forum|alt.badge.img+12
  • Staff
  • November 5, 2025

Hi ​@_RT_ , 
If I understand your ask correctly, the count is usually done by count_distinct() with metadata.event_id field, and for the one-argument problem ; you could concatenate both fields into one and use it for as a match variable.
i.e. could you try this ;

events:
$concatenatedField =  strings.concat($e.<UDM field 1>, $e.<UDM field2>)
...
match:
$catenatedField
Outcome:
$count_catenatedField = count_distinct($e.metadata.event_id)

_RT_
Forum|alt.badge.img+3
  • Author
  • New Member
  • November 10, 2025

Hi ​@_RT_ , 
If I understand your ask correctly, the count is usually done by count_distinct() with metadata.event_id field, and for the one-argument problem ; you could concatenate both fields into one and use it for as a match variable.
i.e. could you try this ;

events:
$concatenatedField =  strings.concat($e.<UDM field 1>, $e.<UDM field2>)
...
match:
$catenatedField
Outcome:
$count_catenatedField = count_distinct($e.metadata.event_id)

Hi ​@AbdElHafez ,

Yes I agree that is the usual solution we adopt. Sorry if I didn’t specify it before, but in this case I am working with a prior calculated variable and not a simple UDM field. So something like:

// conditional logic is actually more complex, but this is the general structure
$placeholder = if(<UDM condition>, "true", "false")

match:
$placeholder, metadata.log_type

outcome:
count_distinct($placeholder, metdatata.log_type) //Not working, but that's the intention

In this case the strings.concat() function does not solve the problem, since it requires plain UDM fields and does not support variables as parameters.

Thanks,


AymanC
Forum|alt.badge.img+13
  • Bronze 5
  • November 13, 2025

Hi ​@_RT_,

Does the below help at all?

 

$holder = if(metadata.log_type = /WIN/, "True", "False")



match:

$holder, metadata.log_type



outcome:

$TotalCount = strings.concat(count_distinct($holder), " + ", count(metadata.id))



unselect:

$holder, metadata.log_type

 

Kind Regards,

Ayman


_RT_
Forum|alt.badge.img+3
  • Author
  • New Member
  • November 21, 2025

Hi ​@AymanC ,

 

Solved the issue using staged queries. Implemented the a stage1 to get the relevant info and then used the concat of such fields in the main body of the search.

 

Thanks anyway!