Hello,

is it possible to show percent value in Views with thumbs up/down widget?

I am using relationship Node: Vote results.
It works when i select value type Points. But I need result in percents!!! :-) (if I select percent I got empty value).

Thanks!

Comments

Kcannick’s picture

I have this exact same question.... I have a site where users rate content with +1 or -1 I want to show/sort nodes based on percentage rather than raw score. When I select Default I receive data but when I select percent its empty

Paradoxetion’s picture

Version: 6.x-1.3 » 7.x-2.x-dev

Ok, here is the solution for Drupal 7.

1. Create two relations Node: Vote results
1.a In first put
Identifier: Vote results
Value Type: Points
Tag: *Your tag*
Aggregation function: Total Score
1.b In second put
Identifier: Vote results 2
Value Type: Points
Tag: *Your tag*
Aggregation function: Number of Votes

2. Create two fields "Vote Results". Let first of them use "Vote results" relation and second one "Vote results 2". Exclude both of them

3. Create "Global: Math expression" field and put there
((([value_1] + [value])/2)/([value_1]))*100
Where [value] is token for field with relation "Vote Results" and [value_1] is token for "Vote Results 2"

check "Round" with 0 Precision

Put % to Suffix

Here you go!

waaadim’s picture

Title: Percent in views » Aggregation function
Version: 7.x-2.x-dev » 7.x-1.3

Hi Paradoxetion, I'm trying to do something similar.
I use the Yes/No widget with options and everything works fine, except the Aggregation function.
If i select anything else than "no filter" i get no results.
Added relations:
Content: Vote results
Content: Votes

amd fields
(Vote results) Vote results: Value (hidden)
(Votes) Votes: Value (hidden)
Global: Math expression (Ranking)

is this a bug or am i missing something ?

Paradoxetion’s picture

Hello waaadim

I guess you should not use "Content: Votes" relation but "Vote results: Value" (yes, you need to add it twice)

Also I'm not sure about "YES|NO widget". Can you open your node with rate widget and press "Vote results" (near "view", "edit") tabs and copy here what you can see there?

Sorry for waiting, missed new post in this topic.

waaadim’s picture

Component: Code » Miscellaneous

There is not really a lot of information there.
It looks like this:
widget name
vote count: 0 (looks like a bug)

Total votes per button
Button Votes
yes 1
no 3
But i don't know how this information can be useful to you. After a few more hours i just created a custom page and queried the voting_results table.

Because after adding those two relationships I was getting duplicates.
Is this happening because of the vote count ?

fruitsalad’s picture

Thank you all for this thread. It helped me a lot. I got one question.

If I want to create a view that shows three nodes. Each node has a thumb up/down widget with percentage. Working really nice with your help.

Now I want to combine the results of these three node to show the percentage of how many people voted for node1, node2 or node3 so I could display a final calculation for the three and not just each node for its own.

Is there a way I could solve this?

fruitsalad’s picture

Issue summary: View changes

mistake

Time has come’s picture

Issue summary: View changes

Thanks @waaadim

Saved my life!

I must not forget about Views Global Math Expression.