Numeric string parsing question

(imported topic written by tostroff91)

I’m writing an analysis that will examine both the absolute free space (in GB) and percentage free space (in percent) on the C: drive of managed clients. I’m running into a logic problem in my Relevance due to the 1st digit of the string containing the disk free space or the percent free space overruling the total value of the number. My disk currently has > 100GB free, so if I run a QnA query to see if the disk space is less than “120” I get a result of True (which is correct) but if I query if it is less than “2” I also get a result of True, since the first digit of “120” is a “1”. I thought I could get around this by using ‘as integer as string’ but it didn’t seem to help. Please see examples below, and let me know what number format to use rather than ‘integer as string’. Thanks!

====================================================

Free Space

Q: (free space of drive “C:” / 1070000000) as integer as string

A: 115

Q: (free space of drive “C:” / 1070000000) as integer as string = “115”

A: True

Q: (free space of drive “C:” / 1070000000) as integer as string < "

A: True

Q: (free space of drive “C:” as integer / 1070000000) integer as string < “2”

A: True

====================================================

Free Percent

Q: (free space of drive “C:” * 100 / total space of drive “C:”) as integer as string

A: 77

Q: (free space of drive “C:” * 100 / total space of drive “C:”) as integer as string = “77”

A: True

Q: (free space of drive “C:” * 100 / total space of drive “C:”) as integer as string <“90”

A: True

Q: (free space of drive “C:” * 100 / total space of drive “C:”) as integer as string <“8”

A: True

(imported comment written by NoahSalzman)

You might try:

(free space of drive “C:” / 1024 / 1024 / 1024 ) > 100

and

((free space of it * 100 / total space of it) > 90) of drive “c:”

(imported comment written by tostroff91)

Thanks Noah - guess I got tied up in strings!

(imported comment written by jessewk)

You might also want to use floating point numbers. Integer math can lead to rounding errors. For example, on my VM:

Q: (free space of drive “C:” / 1024 / 1024 / 1024 )

A: 5

Q: (free space of drive “C:” / 1024 as floating point / 1024 / 1024 )

A: 5.354

Note, once you cast any of the integers as floating point the rest of the calculations will continue to use floating point