简体   繁体   中英

Power BI: Conditional Formating Data bars for Matrix Visual

I need to create a matrix in the following format The total sales and percentage sales below each other:

在此处输入图像描述

This is why I have created a table with data like this:

Salesperson Country Sales Product Format
John USA 0.45 Mountain Bike Percentage
John Canada 0.34 Mountain Bike Percentage
John Italy 0.67 Mountain Bike Percentage
Gina USA 0.43 Mountain Bike Percentage
Gina Canada 0.56 Mountain Bike Percentage
Gina Italy 0.21 Mountain Bike Percentage
Mary USA 0.12 Mountain Bike Percentage
Mary Canada 0.53 Mountain Bike Percentage
Mary Italy 0.12 Mountain Bike Percentage
John USA 0.22 City Bike Percentage
John Canada 0.32 City Bike Percentage
John Italy 0.12 City Bike Percentage
Gina USA 0.11 City Bike Percentage
Gina Canada 0.02 City Bike Percentage
Gina Italy 0.32 City Bike Percentage
Mary USA 0.11 City Bike Percentage
Mary Canada 0.21 City Bike Percentage
Mary Italy 0.32 City Bike Percentage
John USA 2250 Mountain Bike Total
John USA 1700 Mountain Bike Total
John USA 3350 Mountain Bike Total
Gina USA 2150 Mountain Bike Total
Gina Canada 2800 Mountain Bike Total
Gina Italy 1050 Mountain Bike Total
Mary USA 600 Mountain Bike Total
Mary Canada 2650 Mountain Bike Total
Mary Italy 600 Mountain Bike Total
John USA 1100 City Bike Total
John USA 1600 City Bike Total
John USA 600 City Bike Total
... ... ... ... ...

Under Sales column is the total amount and percentage amount of sale and the matrix will filter after the Format column. But since I need to change the format of the percentage to percent, because it's in decimal format, I have created a measure for sales like this:

Sales_all = 
VAR variable = SUM ( 'Table'[Sales])
RETURN
SWITCH (
SELECTEDVALUE ( 'Table'[Format]),
"Total", FORMAT ( variable, "General Number" ),
"Percentage", FORMAT ( variable, "Percent" ))

I have two questions. I would like to create a data bar conditional formatting for Percentage:

  1. Is it possible to use different values for max and min of the data bar for each country. Currently when I choose data bars, I can only enter values for the whole column of Sales, disregarding the Countries (Canada, Italy, USA). For example I would like to enter a max value for Canada as 60% and max value for Italy as 25%. If I use the Sales column directly, not as measure, I can only choose one max value for the whole Sales column. The bar for the percentage should be full at 60% for Canada and full at 25% for Italy.

  2. Since I have used a measure to change the format of the values in Sales column based on the Format column, I can't choose data bar under conditional formatting anymore? Why is this the case and how can I change it?

Please keep each post to a single question. Please don't paste data as images and keep the sample data as copiable text.

I don't understand question 1 so you will need to elaborate (ideally in a brand new question with copiable sample data). The reason for question 2 is that FORMAT() returns text and so is no longer a number and can't produce a data bar. Either keep the measure as a number or change the display formatting using calculation groups.

EDIT

You need to reshape your data. In PQ, pivot Format column with value of Sales as follows:

在此处输入图像描述

You end up with this (missing data because your sample wasn't complete)

在此处输入图像描述

Create a matrix as follows:

在此处输入图像描述

Highlight the column or measure for percentage and in the ribbon select percent for the format. This keeps the underlying value as a number but changes the display only.

在此处输入图像描述

On the matrix, ensure you have the following option.

在此处输入图像描述

You should now have the following:

在此处输入图像描述

You can now add data bars to percentage column.

在此处输入图像描述

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM