Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
danimarc12
Partner - Creator
Partner - Creator

Count with conditions

Hello everyone!

I want to write this expression Count(idOrdine) adding two conditions:

1) if(date(dataGiro)-date(dataOrdine)<=1

2) Num(Frac(dataOrdine))>Num(MakeTime(13,30,00))

What's the correct expression?

I've tried like this: count({<dataOrdine={"num(frac(dataOrdine) > Num(MakeTime(13,30,00))"}>}idOrdine) but It's not working.

Can anyone help me?

Thank you all!

 

1 Solution

Accepted Solutions
Kushal_Chawda

@danimarc12  try below

 count({<idOrdine={"=num(frac(dataOrdine) )> Num(MakeTime(13,30,00)) and dataGiro-dataOrdine<=1"}>}idOrdine)

If idOrdine not primary key of your table then try below

 count({<Primary_key={"=num(frac(dataOrdine) )> Num(MakeTime(13,30,00)) and dataGiro-dataOrdine<=1"}>}idOrdine)

If you don't have primary key or don't know then simply create in load script with rowno() function

View solution in original post

5 Replies
Kushal_Chawda

@danimarc12  try below

 count({<idOrdine={"=num(frac(dataOrdine) )> Num(MakeTime(13,30,00)) and dataGiro-dataOrdine<=1"}>}idOrdine)

If idOrdine not primary key of your table then try below

 count({<Primary_key={"=num(frac(dataOrdine) )> Num(MakeTime(13,30,00)) and dataGiro-dataOrdine<=1"}>}idOrdine)

If you don't have primary key or don't know then simply create in load script with rowno() function

danimarc12
Partner - Creator
Partner - Creator
Author

Thank you Kushal,

I would also add a new condition which is  Anno = {$(=Max(Anno)-1)}  to show the same measure in the last year but it doesn't work, I don't know why.

Also I would like to add a condition like  giro={'*BANCO*'}  to count how many idOrdine for giro which has into the field "BANCO" word. I don't understand why this conditions don't work.

I use to write " , " and add conditions but now it doesn't work.

AshutoshBhumkar
Partner - Specialist
Partner - Specialist

Hi,

How about creating a flag in the script and using those flags in the set ?

danimarc12
Partner - Creator
Partner - Creator
Author

How should I do it?

this is my expression: 

count({<giro={'*PALERMO*'}, idOrdine={"=num(frac(dataOrdine)) > Num(MakeTime(13,30,00)) and dataGiro-dataOrdine<=1"}>}idOrdine)

The first condition (giro=palermo) doesn't work. If I use this  Anno = {$(=Max(Anno)-1)}  or another one, it doesn't work.

AshutoshBhumkar
Partner - Specialist
Partner - Specialist

For giro=palermo you should use giro={"*PALERMO*"}