Solved

How do I create a metric with I am trying to count records that have a NULL value

  • 9 March 2021
  • 2 replies
  • 528 views

Hi

 

I have a fact that can be Null at times.

I can count the records where it is not null

select count(attribute) where fact > 0.

I am trying to count the amount of records that are null.

I do not see anything in the MAQL guide for that. 

Is there a way?

I tried fact = 0 even know I know null is not 0.

I tried fact <=0

 

Neither worked.

 

 

icon

Best answer by Iva Gasparekova 9 March 2021, 16:30

View original

2 replies

Userlevel 3

Hi,

I'd suggest to implement the IFNULL statement into some inner metric, to "enforce" the NULL values firstly. You can even multiple it by "1" if the results do not look as expected. Please check my example below:

SELECT IFNULL(SUM(fact), 0)*1

Then you can adjust your main COUNT metric.

Hi, I have a similar type question. 

I have a metric that counts the events whereby a conversation has been labeled with the attribute “NON-MVP” but I need a metric that counts the conversations that have not been labeled with the attribute “NON-MVP”. 

This is the code that identifies the label being used:

select Inbound Handled Conversations where Conversation Label 8 [Conversation Attribute 8] like "%NON-MVP%"

I tried using this code to identify conversations that have not been labeled “NON-MVP” which does not work:

Select Inbound Handled Conversations where Conversation Label 8 [Conversation Attribute 8] not like "%NON-MVP%"

Any help will be greatly appreciated.

Reply