Skip to main content
Solved

Calculating percentage of a value based on another value.

  • November 7, 2017
  • 3 replies
  • 375 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)
View original
Did this help you find an answer to your question?

3 replies

takashi
Influencer
  • November 7, 2017

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


david_r
Evangelist
  • Best Answer
  • November 7, 2017

Try the following:

0684Q00000ArL5SQAV.png

Expression:

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

Forum|alt.badge.img

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!


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings