Skip to main content

Power BI

Completed

Star Rating Visualization

Vote (35) Share
Jake Carville's profile image

Jake Carville on 07 Jan 2016 17:27:04

It would be brilliant to have a star rating visualization to show ratings on a set scale, possibly from 0-5, or even 10. It would be similar to the rating system on amazon, and would be a great way to display quality metrics.

Comments (19)
Jake Carville's profile image Profile Picture

3a67eb7a 9f67-415f-82e2-837e9854a2c9 on 06 Jul 2020 00:01:18

RE: Star Rating Visualization

My data has the 1 - 5 score. I just need the star visualization of the values. How do I get the stars? (sorry for a beginner question)

Jake Carville's profile image Profile Picture

42aee11b dd38-e811-a955-000d3a1be7ad on 05 Jul 2020 23:20:46

RE: Star Rating Visualization

Why is this marked as completed? I don't see a star-rating viz anywhere.

Jake Carville's profile image Profile Picture

bde7db48 02e9-4991-b92c-6ff319e55d3c on 05 Jul 2020 23:09:54

RE: Star Rating Visualization

I have problems when I try to show this custom visual. The star doesn't update when there is no data.

Jake Carville's profile image Profile Picture

09baa087 cc9e-48dd-8785-36cc10f9302e on 05 Jul 2020 22:59:16

RE: Star Rating Visualization

Can you please tell me how to download this visual.. Its not there in office store

Jake Carville's profile image Profile Picture

d6463516 68e7-4bac-9fa0-8f85b458a521 on 05 Jul 2020 22:53:58

RE: Star Rating Visualization

Hello Everyone,

I have created quick measure "Star Rating" based on sales value but I dont the Value for highest star rating. Sales value either be Million or Billion or less.

How I want to set MAX_RATED_VALUE dynamic based on sales? Can you please help me on this ?

Sales_LCD star rating =
VAR __MAX_NUMBER_OF_STARS = 5
VAR __MIN_RATED_VALUE = 0
VAR __MAX_RATED_VALUE = 1000000
VAR __BASE_VALUE = SUM('Pfizer Champix QTR'[Sales_LCD])
VAR __NORMALIZED_BASE_VALUE =
MIN(
MAX(
DIVIDE(
__BASE_VALUE - __MIN_RATED_VALUE,
__MAX_RATED_VALUE - __MIN_RATED_VALUE
),
0
),
1
)
VAR __STAR_RATING = ROUND(__NORMALIZED_BASE_VALUE * __MAX_NUMBER_OF_STARS, 0)
RETURN
IF(
NOT ISBLANK(__BASE_VALUE),
REPT(UNICHAR(9733), __STAR_RATING)
& REPT(UNICHAR(9734), __MAX_NUMBER_OF_STARS - __STAR_RATING)
)

Jake Carville's profile image Profile Picture

3f88f7ae 167c-4cc0-8dfa-bf93d3955e80 on 05 Jul 2020 22:30:24

RE: Star Rating Visualization

Jake

I was wondering if the code for this custom visual is available anywhere. I have been trying to source something similar to what you have created in Stars. Only problem is that instead of a maximum of 5, I would like to to be about 100. Really just a visual representation of an integer.

Jake Carville's profile image Profile Picture

52b5cce4 5162-45fc-a468-4609777326e8 on 05 Jul 2020 22:17:17

RE: Star Rating Visualization

What an excellent visual, exactly what I was looking for in terms of look, feel and functionality. A big thanks to Tim Sawyer for a brilliant visual and to Pedro Innecco for all his help.

Jake

Jake Carville's profile image Profile Picture

1f7f2711 5819-e611-80e2-c4346bad91c4 on 05 Jul 2020 22:17:11

RE: Star Rating Visualization

I am glad that I could help! :)

Basically Wikicommons have those stars available as images that you can download. And you can have it to automatically generate the thumbnails with the size that you want. Note the "100px" bit on the url. You can change to any size you want.

Jake Carville's profile image Profile Picture

52b5cce4 5162-45fc-a468-4609777326e8 on 05 Jul 2020 22:16:49

RE: Star Rating Visualization

Hi again Pedro,

I have to say that is a nice formula that you have put together that works beautifully to automate a Star Rating type chart, many thanks.

Originally I was importing an image manually but this is a lot more streamlined and a big step up so thank you.

I have found the Power BI community to be very creative and helpful.

Regards,
Jake

Jake Carville's profile image Profile Picture

1f7f2711 5819-e611-80e2-c4346bad91c4 on 05 Jul 2020 22:16:41

RE: Star Rating Visualization

'Hi Jake,

I had another thought about this and you could easily show the stars on a table by using a text field configured as "Image URL". This Image URL column would be a calculated column with a DAX formula to show the stars. The DAX formula would be a simple SWITCH statement to show the correct number of stars based on the rating.

Now it would be better if the rating is a static column coming from the underlying database which is already in the ratio you want to use for the stars. Or you could make a calculated column to change whatever scale you have for the rating in order to follow the star rating scale.

Check out the code below. I made it using the thumbnail of stars I got from Wikicommons. You could easily save those somewhere else if you want to. If you go to the Wikicommons site you can also generate the URL for any thumbnail size you want.

=SWITCH([RatingColumn],
0.5 , "https://upload.wikimedia.org/wikipedia/commons/thumb/4/40/0.5_stars.svg/100px-0.5_stars.svg.png",
1 , "https://upload.wikimedia.org/wikipedia/commons/thumb/4/40/0.5_stars.svg/100px-0.5_stars.svg.png",
1.5 , "https://upload.wikimedia.org/wikipedia/commons/thumb/c/c6/1.5_stars.svg/100px-1.5_stars.svg.png",
2 , "https://upload.wikimedia.org/wikipedia/commons/thumb/8/88/2_stars.svg/100px-2_stars.svg.png",
2.5 , "https://upload.wikimedia.org/wikipedia/commons/thumb/2/2d/2.5_stars.svg/100px-2.5_stars.svg.png",
3 , "https://upload.wikimedia.org/wikipedia/commons/thumb/4/4e/3_stars.svg/100px-3_stars.svg.png",
3.5 , "https://upload.wikimedia.org/wikipedia/commons/thumb/e/ee/3.5_stars.svg/100px-3.5_stars.svg.png",
4 , "https://upload.wikimedia.org/wikipedia/commons/thumb/1/1b/4_stars.svg/100px-4_stars.svg.png",
4.5 , "https://upload.wikimedia.org/wikipedia/commons/thumb/b/b9/4.5_stars.svg/100px-4.5_stars.svg.png",
5 , "https://upload.wikimedia.org/wikipedia/commons/thumb/a/ae/5_stars.svg/100px-5_stars.svg.png",
"https://upload.wikimedi