Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
Hello.
I have sales data for number of products sold per staff member that looks like this, with the totals being calculated vertically, how can it be calculated horizontally as well?
My data:
Name Gloves Hats Scarfs
James 3 2 4
Jane 1 3 2
Chris 0 1 1
Power Bi adds the total as summing vertically:
Total 4 6 7
How can I make it look like this?
Name Gloves Hats Scarfs Total
James 3 2 4 10
Jane 1 3 2 6
Chris 0 1 1 2
I guess I have to create a measure? I don't want the Total vertically, just horizontally.
Many thanks.
Solved! Go to Solution.
You can go to Format pane of your table, and there should be an option for grand total that you can turn it off to remove Total. As for displays 0, you can write the following:
Sales Total =
VAR temp = SUMX(Sales, Sales[Hat] + Sales[Scarf] + Sales[Gloves])
RETURN IF(temp = BLANK(), 0, temp)
Hi,
Your data is not well structures. It should ideally be a 3 column dataset - Name, Item and Value. The item column should have Gloves, Scarfs and Hats. To do so, in the Query Editor window, right click on the first column and select "Unpivot other columns". Click on Close and Load. Now build your visual.
You can create a measure like this:
Total = SUMX(Sales, Sales[Gloves] + Sales[Hats] + Sales[Scarfs])
Then simple drag it to your table
Hello @Anonymous.
Your measure worked great, thank you!
I used it to make this table:
Month | Hat | Scarf | Gloves | SalesTotal |
March | 1 | 6 | 4 | 11 |
Total | 1 | 6 | 4 | 11 |
In the above, SalesTotal is your measure, and works great, but Total is calculated by Power Bi - how do I remove it?
Also, how can SalesTotal be edited so that if some products have no sales, it displays 0 instead of being blank?
Many thanks.
You can go to Format pane of your table, and there should be an option for grand total that you can turn it off to remove Total. As for displays 0, you can write the following:
Sales Total =
VAR temp = SUMX(Sales, Sales[Hat] + Sales[Scarf] + Sales[Gloves])
RETURN IF(temp = BLANK(), 0, temp)
Thanks very much for this, @Anonymous. Let me try it out and see.
User | Count |
---|---|
140 | |
113 | |
104 | |
77 | |
65 |
User | Count |
---|---|
135 | |
117 | |
101 | |
71 | |
61 |