Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Dear all
I am working with the following data and is required to list the genres of movies that Lawyers liked the most (based on Rating).
I need to create a bar chart to list the Title and the Total Rating (only ratings by Lawyers and exclude all other occupation).
What codes do I place in my expression to calculate the total ratings of lawyers only?
Thank you!
MovieID | Title | Rating | Genres | UserID | Gender | Occupation |
1 | Toy Story (1995) | 5 | Animation | 719 | M | Lawyer |
2 | Jumanji (1995) | 4 | Adventure | 1056 | M | Student |
3 | Grumpier Old Men (1995) | 4 | Comedy | 1187 | F | Lawyer |
4 | Waiting to Exhale (1995) | 5 | Comedy | 1200 | M | Lawyer |
5 | Father of the Bride Part II (1995) | 5 | Comedy | 1296 | M | Lawyer |
6 | Heat (1995) | 4 | Action | 1458 | M | Teacher |
7 | Sabrina (1995) | 5 | Comedy | 1509 | M | Lawyer |
8 | Tom and Huck (1995) | 3 | Children's | 1573 | M | Student |
9 | Sudden Death (1995) | 4 | Action | 1919 | M | Lawyer |
10 | GoldenEye (1995) | 3 | Action | 1926 | F | Lawyer |
11 | American PresidentThe (1995) | 3 | Drama | 2045 | F | Teacher |
12 | Dracula: Dead and Loving It (1995) | 5 | Horror | 2120 | M | Student |
13 | Balto (1995) | 5 | Children's | 2169 | M | Student |
14 | Nixon (1995) | 5 | Drama | 3234 | F | Lawyer |
15 | Cutthroat Island (1995) | 5 | Action | 3594 | M | Lawyer |
16 | Casino (1995) | 4 | Thriller | 3780 | M | Lawyer |
17 | Sense and Sensibility (1995) | 4 | Drama | 4633 | M | Lawyer |
18 | Four Rooms (1995) | 5 | Thriller | 4707 | M | Teacher |
19 | Ace Ventura: When Nature Calls (1995) | 5 | Comedy | 5074 | M | Lawyer |
Hi Jess,
Use set analysis, something like:
avg({<Occupation={"Lawyer"}>}Rating)
This part {<Occupation={"Lawyer"}>} is making the selection for lawyers only.
Felipe.
Hi Jess,
Use set analysis, something like:
avg({<Occupation={"Lawyer"}>}Rating)
This part {<Occupation={"Lawyer"}>} is making the selection for lawyers only.
Felipe.
Hi Felipe
Thank you for helping. I'm sorry but my coding skills are bare minimal.
This is my code used but my bar chart is showing the wrong data.
Aggr(Avg({<Occupation={"Lawyer"}>}Rating),GenreCategory)
Do you need this in a KPI Object? May be this
=FirstSortedValue({<Occupation={'Lawyer'}>} GenreCategory, -Aggr(Avg({<Occupation={'Lawyer'}>}Rating), GenreCategory))
Thank you Sunny. I'm not sure what a KPI Object is but I understand the firstsortvalue action.
I'm still not getting any data in my chart
What are the chart dimension where you are using this expression?
It's GenreCategory (which would be the y-axis on my bar chart)
I meant x-axis
Then use this as your expression as suggested by felipedl
avg({<Occupation={"Lawyer"}>}Rating)
Can I check and clarify why Avg is used instead of Sum?
Should it not sum the total ratings for Lawyers?
Sum({<OccGroup={"Lawyer"}>}Rating)