Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Adjust the star rating with halves

Hi there,

 

I created this measure for stars: 

Star Rating = 
IF(HASONEVALUE(Forms[Rating]),  BLANK(),
LEFT(REPT(UNICHAR(9733), AVERAGE(Forms[Rating]))  
&  
REPT(UNICHAR(9734), 5-AVERAGE(Forms[Rating])),5))

Yet I need to make the visual more granulated, so it shows half stars as well or anything along the lines. Do you have any idea how to achieve this? I am also open to other solutions, maybe some icons? 

AndrejBI_0-1613552457982.png

 

 

1 ACCEPTED SOLUTION
cookieking
Frequent Visitor

 

I have been playing around with this for a day or so. I have found that the unichar support for 11 is not available in power bi yet, for half stars. I created single star images and tried the REPT function, but that also failed. I guess that once it is set as an Image URL, the REPT function converts it back to a string. Then I created about 15 images for all 5 stars ratings that range from 1, 1.25, 1.5 through to 5. I converted the images to base64. I added this data to a table in my report. In addition, I named the images according to their rating value. With this, I was able to create a measure with a LOOKUP and get the correct star rating based on the average rating value:

 

 

 

 

Star = 
var decRAR = MROUND(AVERAGE('Ratings'[Rating]),0.25)
return
LOOKUPVALUE('FiveStar'[img],'FiveStar'[imgName],decRAR)

 

 

 

 

 

this works great, except for my image size. The actual size is 371 X 65, which seems large, but they are too small to read when added to a table. The only size setting I could find in the table was under GRID, Image Height. when I increase the height, the row height also increases, and the formatting does not look good. What is the best way to size these images?

View solution in original post

4 REPLIES 4
cookieking
Frequent Visitor

 

I have been playing around with this for a day or so. I have found that the unichar support for 11 is not available in power bi yet, for half stars. I created single star images and tried the REPT function, but that also failed. I guess that once it is set as an Image URL, the REPT function converts it back to a string. Then I created about 15 images for all 5 stars ratings that range from 1, 1.25, 1.5 through to 5. I converted the images to base64. I added this data to a table in my report. In addition, I named the images according to their rating value. With this, I was able to create a measure with a LOOKUP and get the correct star rating based on the average rating value:

 

 

 

 

Star = 
var decRAR = MROUND(AVERAGE('Ratings'[Rating]),0.25)
return
LOOKUPVALUE('FiveStar'[img],'FiveStar'[imgName],decRAR)

 

 

 

 

 

this works great, except for my image size. The actual size is 371 X 65, which seems large, but they are too small to read when added to a table. The only size setting I could find in the table was under GRID, Image Height. when I increase the height, the row height also increases, and the formatting does not look good. What is the best way to size these images?

v-yangliu-msft
Community Support
Community Support

Hi  @Anonymous  ,

You can try to select Get more visuals in Visualizations to enter the custom visual object store

v-yangliu-msft_0-1613695080227.jpeg

2. Search for Stars and find Ratings View by TME AG.

v-yangliu-msft_1-1613695080232.png

3. This graphic can display more accurate Stars and interact with other views.

v-yangliu-msft_2-1613695080233.jpeg

You can downloaded PBIX file from here.

 

For related information about Star Rating, you can check the following link:

https://www.youtube.com/watch?v=T5IKZSlFSNc

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Hi @amitchandak, yes I was inspired by these articles to create my measure. My question is about half to make it more granular, as it's a huge difference to have a 5-star rating for 4.9 and 4.51. I know there is a unicode for half a star but I can't get nor find the logic to make it work. 

 

Also, both of the articles are from 2018, so I was hoping for some updated version for this solution 🙂 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors