Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Tarek2020
Contributor
Contributor

Qlik Sene Avg for null values

Hi evryone,

can someone help me please with thi issue?

 

I have a  table with 5 fields. the calculation should be for the null distance values:

If( isnull(distance), calculate the avg of distance where Consignee Zip , Consignor Zip, Consignee Zip Code, Consignor Zip code is the same.

for example in the second row should be the avg of 67 and 12 means 39,5.

Shipment noConsignee Zip Consignor Zip Consignee Zip CodeConsignor Zip codeDistance
144233467
24423340
344233412
45566400
555660
655660
755660
Labels (4)
3 Replies
sonkumamon
Creator
Creator

I would do it on the script level, for instance:

TempTable:

Load

[Shipment no],

[Consignee Zip],

[Consignor Zip],

[Consignee Zip Code],

[Consignor Zip code]

From...

Where Distance=0;

Left Join

Load

[Consignee Zip],

[Consignor Zip],

[Consignee Zip Code],

[Consignor Zip code],

Distance

From...;

 

Table:

[Shipment no],

Avg(Distance) as Distance

Resident TempTable

Group By [Shipment no];

 

And you will get the average of the distance where the other columns are similar for Shipment No with distance of 0.

Tarek2020
Contributor
Contributor
Author

Hi Sonkumamon,

thank you for your message. Unfortunately it does not working. I am searching for a logic for the frontend.

sonkumamon
Creator
Creator

It is very difficult to achieve in the frontend, and would have a negative impact on the performance. What is not working as expected in my solution?