Skip to main content

Hi there,

I've searched a few threads on here about calculating percentages, but nothing seems to quite summarize what I'm looking for.

I have several polygons, each containing an attribute of "TotalKm" and "MinorKm"

The "MinorKm" represents roads inside that are of a lower class or quality.

I simply want to calculate the percentage based on the "TotalKm", like this example:

MinorKmTotalKmPercentageKm156025%15020075%

I tried playing around with the ExpressionEvaluator to do this, but I could't quite create the correct expression for this.

Thanks in advance,

I think the ExpressionEvaluator should work fine. What expression have you set and what happened?


Try the following:

0684Q00000ArL5SQAV.png

Expression:

@Value(MinorKm)*100.0/@Value(TotalKm)

Hi takashi,

Well I've tried a few with little success, but as embarrassing as it is to share this here, this is the chaotic string I came up with last (Math fail) :)

@Value(TotalKm)-@Value(Minorkm)/@Value(TotalKm)*100

David's expression works perfectly, and is also much more elegant :)

Thanks a lot to both of you!


Reply