Solved

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

  • 9 March 2021
  • 1 reply
  • 333 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

1 reply

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.

Reply