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
Dear Community,
I have a large table of sales transaction datafor all our cleints and all the respective products of ours they have purchased over time.
I would like some DAX to add a column and tag each client with a prefered product which i have defined as the product they have spent the most on over their lifetime with the company.
Client | Product | Value | DESIRED NEW COLUMN Prefered Product |
111 | A | 5 | A |
112 | B | 5 | B |
111 | A | 5 | A |
112 | B | 5 | B |
111 | B | 5 | A |
112 | A | 5 | B |
I have attempted the following:
Solved! Go to Solution.
@StephenClarke
You can add the following column to get the desired result. I found additional columns in your formula that was not in the sample data you provided, I hope you can adjust the following formula to suit your columns,
Top Programme =
var __Client = Booking[ClientID]
var ClientProductAmount =
TOPN(1,
ADDCOLUMNS(
SUMMARIZE(
FILTER(Booking, Booking[ClientID] = __Client),
Booking[Product]
),
"Amount", CALCULATE(SUM(Booking[Value]))
),
[Amount]
)
return
MAXX(ClientProductAmount,Booking[Product])
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
Genius!
Thank you so much for the replies.
Hi,
Do you want a measure or a calculated column formula?
@StephenClarke
You can add the following column to get the desired result. I found additional columns in your formula that was not in the sample data you provided, I hope you can adjust the following formula to suit your columns,
Top Programme =
var __Client = Booking[ClientID]
var ClientProductAmount =
TOPN(1,
ADDCOLUMNS(
SUMMARIZE(
FILTER(Booking, Booking[ClientID] = __Client),
Booking[Product]
),
"Amount", CALCULATE(SUM(Booking[Value]))
),
[Amount]
)
return
MAXX(ClientProductAmount,Booking[Product])
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
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 |
---|---|
124 | |
87 | |
85 | |
70 | |
51 |
User | Count |
---|---|
205 | |
153 | |
97 | |
79 | |
69 |