Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
josecanalla
Creator
Creator

Divide values with column null

I have a table with the expenses of truck drivers. One of the columns of this table, is the "driver_id".

Sometimes, the "driver_id" is null because of the expense is not imputable to any driver. I want to get all of the expenses with driver_id null and divide that value into all of the drivers. How can I do it in Qlik Sense?

For example:

$500 of expenses with driver_id null. Then if I have 5 drivers, I want to put $500/5 = $100 to each driver and show it, for example, in a pivot table.

3 Replies
devarasu07
Master II
Master II

hi,

Try like this

Your dimension

=if(len(driver_id)>0,driver_id)

note: remember to suppress the null value

measure:

sum( total{$<driver_id ={"=len(driver_id)<=0"}>}expenses)/count(total  distinct {$<driver_id ={"=len(driver_id)>0"}>} driver_id)

Capture.JPG

Capture.JPG

prasadmundewadi
Contributor III
Contributor III

Try this

Sum(if(IsNull(driver_id),Expense))/Count(distinct (driver_id))

josecanalla
Creator
Creator
Author

It works and with this I can get the total of expenses with driver_id null.

But now how can I sum this value in a pivot table with "driver_id" and "product_id" as rows, "monthyear" as column, and "total" (which is a sum) as measure?