I have a matrix visualisation in Power BI. I dragged a date field to the rows section. I dragged nothing to the columns section. I dragged three amount fields to the values section.
the matrix visualisation on the page shows a matrix with
column 1 : the date field
column 2 : the first amount field
column 3 : the second amount field
column 4 : the third amount field
in other words, Power BI shows the fields from the values section as columns. great!
How can I easily show a total for each row? Power BI ignores the setting to show column totals, because I dragged nothing to the columns section.....
The Matrix visual will only total the same metric, and in your case you have three different metrics in the Values
well.
There are several solutions - below is the proper solution, the others solutions like using visual calculations or creating a measure to sum the three amounts will not display as Total in the matrix.
Proper (native visual) total
Create a new table in your model for the columns of the matrix.
As an example table named Dim Amount
Amount type | Amount sort |
---|---|
Amount A | 1 |
Amount B | 2 |
Amount C | 3 |
Then create a Measure similar to:
Amount w/ Dim =
var amtA = SUM(YourTable[Your first Amount column])
var amtB = SUM(YourTable[Your second Amount column])
var amtC = SUM(YourTable[Your third Amount column])
return
SWITCH(
SELECTEDVALUE('Dim Amount'[Amount type]),
"Amount A", amtA,
"Amount B", amtB,
"Amount C", amtC,
amtA + amtB + amtC
)
Now in your Matrix, add this new measure to your Values
and 'Dim Amount'[Amount type]
to your columns.
(FYI, if you add Date in rows, then add Amount type to columns without the measure in Values, you will get a visual error saying it can't determine relationship... Not to worry, as soon as you add the measure to the Values this is will all be good.)
There is another option but it requires modifying your model to unpivot those three columns. For example, going from:
Key | Amount A | Amount B | Amount C |
---|---|---|---|
1 | 1 | 10 | 100 |
2 | 2 | 20 | 200 |
3 | 3 | 30 | 300 |
To:
Key | Amount type | Amount |
---|---|---|
1 | Amount A | 1 |
1 | Amount A | 10 |
1 | Amount A | 100 |
2 | Amount B | 2 |
2 | Amount B | 20 |
2 | Amount B | 200 |
3 | Amount C | 3 |
3 | Amount C | 30 |
3 | Amount C | 300 |
This can be done via Power Query relatively easily.