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

Measure to display percentage

Hello all,

my issue is a little complex:

I created a report in which you can change what a visual displays via a slicer, similiar to this post: 

Dynamically change the information within a visual via a slicer - oxcrx34285 (powerbi.com)

 

Anyway, now I want to be able to switch between a visual being displayed in total and percent.

However, if I just change the display type to percent", 610 just becomes 61000% so no real solution.

The visuals affected all have a legend, what makes it even more difficult, look here:

 

61.PNG

So right now I have no idea how to display it. I can't just change the data labels to percent or load the values as %GT as in the end of the day in the report it is intended that the user just presses a button and it changes from total to percent.

 

Right now I have two ideas:

1. Creating a bookmark but that complicates the report structure for my successors and also everytime you change something you have to take care to change it in the bookmark too.

2. Creating calculated columns. Same: complicates the structure and adds a bunch of calculated columns as I have to do this for all my visuals so it will also affect loading time.

 

So maybe if there is an expression that calculates the value displayed per category, divides it through all values displayed and shows the outcome in percent, that would be what I'm looking for.

Any help would be much appreciated.

 

EDIT: I can't just Divide through the sum of the column as through many slicers& filters, not all values are displayed.

1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @Anonymous ,

 

You need to use the Calculation groups to do this .

 

Even in live connection you can use calculation groups and create this changes, follow the step below:

  • Assuming you already have Sales Measure
  • On external tools execute the Tabular editor

MFelix_0-1602169947918.png

  • Rigth Click on Tables
  • New Calculation Group

MFelix_2-1602170081096.png

 

  • Rename as you need
  • Rigth click
  • New Calculation Item

MFelix_1-1602170020388.png

 

  • Rename it sales and write the folllowing code:
SELECTEDMEASURE()
  • Add two new calculation items with the formulas you have in the Power BI for the other two measures, if your measure in Power BI is for example: DIVIDE(SUM(Table[Column]), SUM(Table[Column2]) this is the formula you must place on the calculation item.
  • On the Percentage formula make your formatting as %

MFelix_3-1602170461284.png

 

  • Save the model

MFelix_4-1602170491710.png

 

  • Go back to Power BI and refresh the model you should see your new table in the model
  • Now create your line chart with the following setup:.
    • Axis: Column you need
    • Values: Measure Sales
    • Legend: Column from the calculated group table
  • Slicer: Column from calculated group table

Check result below:

Calculation_groups.gif

 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

1 REPLY 1
MFelix
Super User
Super User

Hi @Anonymous ,

 

You need to use the Calculation groups to do this .

 

Even in live connection you can use calculation groups and create this changes, follow the step below:

  • Assuming you already have Sales Measure
  • On external tools execute the Tabular editor

MFelix_0-1602169947918.png

  • Rigth Click on Tables
  • New Calculation Group

MFelix_2-1602170081096.png

 

  • Rename as you need
  • Rigth click
  • New Calculation Item

MFelix_1-1602170020388.png

 

  • Rename it sales and write the folllowing code:
SELECTEDMEASURE()
  • Add two new calculation items with the formulas you have in the Power BI for the other two measures, if your measure in Power BI is for example: DIVIDE(SUM(Table[Column]), SUM(Table[Column2]) this is the formula you must place on the calculation item.
  • On the Percentage formula make your formatting as %

MFelix_3-1602170461284.png

 

  • Save the model

MFelix_4-1602170491710.png

 

  • Go back to Power BI and refresh the model you should see your new table in the model
  • Now create your line chart with the following setup:.
    • Axis: Column you need
    • Values: Measure Sales
    • Legend: Column from the calculated group table
  • Slicer: Column from calculated group table

Check result below:

Calculation_groups.gif

 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



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.