Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #1
Kcannick CreditAttribution: Kcannick commentedI 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
Comment #2
Paradoxetion CreditAttribution: Paradoxetion commentedOk, 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!
Comment #3
waaadim CreditAttribution: waaadim commentedHi 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 ?
Comment #4
Paradoxetion CreditAttribution: Paradoxetion commentedHello 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.
Comment #5
waaadim CreditAttribution: waaadim commentedThere 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 ?
Comment #6
fruitsalad CreditAttribution: fruitsalad commentedThank 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?
Comment #6.0
fruitsalad CreditAttribution: fruitsalad commentedmistake
Comment #7
Time has come CreditAttribution: Time has come commentedThanks @waaadim
Saved my life!
I must not forget about Views Global Math Expression.