Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Save $650 on Qlik Connect, Dec 1 - 7, our lowest price of the year. Register with code CYBERWEEK: Register
cancel
Showing results for 
Search instead for 
Did you mean: 
kjun7603
Contributor
Contributor

Variable not working in a chart

Hi,

I have a variable, vAvgHours, which returns an average hours of some data. 

And I compare the value of the variable in a chart but the comparison result is not consistent. 

In the screenshot below, Col1 is $(vAvgHours) and Col2 is $(vAvgHours)>= 1, but as the result is -1 for the first case and 0 for the second case, even though their values are the same.

kjun7603_0-1673033372323.png

Please let me know if I need to include more details in this ticket.

Thanks.

 

Labels (1)
6 Replies
rubenmarin

Hi, what expression is stored in vAvgHours? It could be better if you can upload a qvw with the sample to check what is behind that chart.

kjun7603
Contributor
Contributor
Author

Thanks, Rubenmarin. It turned out that  aggr calculations (it doesn't necessarily have to be a variable) are not working.

I attached a qvw file with data loaded. I included a table box with the original source and a table chart with the calculation that I need to figure out. Please let me know if you need more details.

MayilVahanan

HI

Might be, try like below

((SUM(AttMinutes)/60.0)/AVG(TargetHours)) >= 1

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
rubenmarin

Hi, dividing 40 by 60 is, 0,6666... and by the limits of number lengh at the end Qlik puts a 7, so it's not exactly a third, and when converted to binary it can also lose some precission with decimals.

As suggested by @MayilVahanan it will be better to do the division outside the sum.

Also you can add a round to limit the decimals used in the comparison, like:

Round(SUM(AttMinutes)/60,0.01)/Round(AVG(TargetHours),0.01)>=1

kjun7603
Contributor
Contributor
Author

Thank you for your reply, @rubenmarin.

That makes sense what happened in the real dashboard (the one I posted here is a sample because of the complexity) is it rounds up for the most of cases but only two lose the precision with decimals. If all lost the precision, it would be easier to find the root cause, but 16 cases out of 18 returned rounded number and two returned the result without some decimal points.

My problem is resolved but if you can find out the reason of the inconsistent output, that will be great.

Thanks!

rubenmarin

Hi @kjun7603, in the sample all have the same data, if you can upload a sample with the data of those 2 cases I can take a look to see what's happening.