March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hello DAX Gurus,
I am having trouble with a relatively simple matter:
I have 1 table with sales transactions, per customer, per product, per day.
Created a measure [Sales Vol..] which Sums the column for sales value.
I am creating the below table as a visual, and need to have for each Customer-Product row, the sales for the product in the row, and in another column the total sales of that customer (depicting the sum of the red rectangles.
The below measure is not working, it shows the sales of the current product, not the sum of all product for that particual customer.
Thanks in advance, your time is greatly appreciated.
Aminek
Solved! Go to Solution.
@akhoury - I believe I got this:
Measure 11 =
VAR __Customer = MAX('Table (11)'[Customer ID])
VAR __Sum = SUM('Table (11)'[Sales vol])
VAR __Total = SUMX(FILTER(ALL('Table (11)'),[Customer ID]=__Customer),[Sales vol])
RETURN
DIVIDE(__Sum,__Total,0)
PBIX attached below sig, Page 11
@akhoury , seems like you need sun total
then try like the example
Calculate(Sum(Table[Sales Vol]), allexcept(Table, Table[ID]))
Calculate(Sum(Table[Sales Vol]), filter(allselected(Table), Table[ID] = Max(Table[ID])))
Change the column as per need
Refer example
https://community.powerbi.com/t5/Desktop/Percentage-of-subtotal/td-p/95390
Thanks for your reply @amitchandak .
Unfortunatly, those did not work. I had already tried them and retried them now.
Using Allexcept hangs and runs out of memory.
And filtering by ID=MAX(ID) returns sales of current product. Not summing all products for same customers.
@akhoury ,Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.
Thanks for replying @amitchandak .
Below is the table in my model (called SALES) on which Im doing those calculations:
Date | Customer ID | Product | Sales vol |
05/04/2020 | 4729 | SKU 82 | 34.6 |
06/01/2020 | 4729 | SKU 89 | 80.6 |
03/05/2020 | 4729 | SKU 89 | 92.2 |
06/01/2020 | 4729 | SKU 9 | 63.4 |
16/03/2020 | 6942 | SKU 122 | 451.2 |
13/04/2020 | 6942 | SKU 116 | 374.4 |
04/05/2020 | 6942 | SKU 116 | 374.4 |
I have a measure that sums the Sales column: Sales Volume = SUM(sales[Sales vol])
My end objective is, to calculate the % share for every Product bought by every customer. And for this, all Im missing is the total sales per customer.
Resulting Table visual as such:
Customer ID | Product | Sales | Total sales per customer | % share |
4729 | SKU 82 | 34.6 | 270.8 | 13% |
4729 | SKU 89 | 172.8 | 270.8 | 64% |
4729 | SKU 9 | 63.4 | 270.8 | 23% |
6942 | SKU 122 | 451.2 | 1200.0 | 38% |
6942 | SKU 116 | 748.8 | 1200.0 | 62% |
% share is just the division of Sales by 'Total Sales per Customer'; what Im missing is Total sales per customer.
Ideally I would need a measure for this. I know how to do it using a Calculated Columns with the EARLIER function, but its quite inefficient from a performance point of view. The table has 4-5millions of rows.
Thanks in advance for your help.
Aminek
@akhoury - Can you just use Show value as | Percent of Grand Total?
Apologies for the delay @Greg_Deckler - swamped..
The Gran Total is the total volume of all customers. What I need is the total volume per customer as a measure so to later use it to calculate the Product Shares within each customer.
Hi @akhoury ,
USe these measures
Thanks for your reply @harshnathani .
Unfortunatly I am getting a different (and weird) result than yours.
As in the screenshot below - Product IDs as well as the Sales values disappear and the Total sales per customer seem to be way higher than it should. Possibly summing all the column:
Thanks for replying @harshnathani . Unfortunatly it will take me too much time to anonimize the company's PBI file. It's quite large.
However, I found the cause of the proble, but I'm not able to solve it: It seems that the below DAX measure..
Total volume per customer = CALCULATE(SUM(oos_sales[sales - volume (L)]), ALLEXCEPT(oos_sales,oos_sales[customer_unique_code]))
Thanks for the help. Much appreciated.
Aminek
@akhoury - I believe I got this:
Measure 11 =
VAR __Customer = MAX('Table (11)'[Customer ID])
VAR __Sum = SUM('Table (11)'[Sales vol])
VAR __Total = SUMX(FILTER(ALL('Table (11)'),[Customer ID]=__Customer),[Sales vol])
RETURN
DIVIDE(__Sum,__Total,0)
PBIX attached below sig, Page 11
Awesome - works perfect. Nice trick using the cust_ID=Max(Cust_ID) - I didnt know it works on Texts/strings same as with numbers.
Thanks @Greg_Deckler for the solution and to all others that share their thoughts.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
25 | |
18 | |
15 | |
9 | |
8 |
User | Count |
---|---|
37 | |
32 | |
21 | |
16 | |
14 |