Skip to main content
Solved

Calculating percentage of a value based on another value.

  • November 7, 2017
  • 3 replies
  • 485 views

Forum|alt.badge.img

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,

Best answer by david_r

Try the following:

0684Q00000ArL5SQAV.png

Expression:

@Value(MinorKm)*100.0/@Value(TotalKm)
This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

3 replies

takashi
Celebrity
  • 7843 replies
  • November 7, 2017

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


david_r
Celebrity
  • 8394 replies
  • Best Answer
  • November 7, 2017

Try the following:

0684Q00000ArL5SQAV.png

Expression:

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

Forum|alt.badge.img
  • Author
  • 70 replies
  • November 7, 2017

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!