Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi, I have a table with thousands of sales orders. I want a new column which calculates the amount of discount a customer received on their first order (ensuring first order status equals "processing" or "completed"). Below is a sample of the table (which has many more columns but I have reduced it to illustrate the problem).
Solved! Go to Solution.
Hi,
Write these calculated column formulas
First created date = CALCULATE(MIN(Data[date_created]),FILTER(Data,Data[Unique ID]=EARLIER(Data[Unique ID])&&(Data[Order Status]="Completed"||Data[Order Status]="Processing")))
First discount received = LOOKUPVALUE(Data[discount_total],[date_created],[First created date],[Unique ID],[Unique ID],[Order Status],"Completed")
Hope this helps.
@Anonymous maybe tweak it like this:
first discount =
CALCULATE (
SUM ( Sheet1[discount_total] ),
(
TOPN (
1,
FILTER (
ALLEXCEPT ( Sheet1, Sheet1[Unique ID] ),
Sheet1[Order Status] IN { "Completed", "Processing" }
),
MIN ( Sheet1[date_created] ),
ASC
)
)
)
✨ Follow us on LinkedIn
Check my latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!
⚡ Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.⚡
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Thanks but it doesn't seem to work. There is an error 'A circulancy dependency was detected'
Thanks, I'll give it a try
@Anonymous add this measure:
first discount =
CALCULATE (
SUM ( Sheet1[discount_total] ),
(
TOPN ( 1, ALLEXCEPT ( Sheet1, Sheet1[Unique ID] ), ( MIN ( Sheet1[date_created] ) ), ASC )
)
)
✨ Follow us on LinkedIn
Check my latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!
⚡ Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.⚡
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Thanks, appreciate it. It appears to be missing the filter for order status (Completed or processing)?
@Anonymous what is a customer in that file? I don't see a customer column? Also, it is good to explain the expected output.
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Unique ID is the customer ID. This is a full list of sales, For each row I would like to see the amount of discount that customer received for their first order. For wider context, It is apart of a churn model I am putting together, I am trying to see how long customers stay depending on the level of discount they received when they initially joined.
@Anonymous share using One drive/google drive.
✨ Follow us on LinkedIn
Check my latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!
⚡ Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.⚡
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Hi,
Write these calculated column formulas
First created date = CALCULATE(MIN(Data[date_created]),FILTER(Data,Data[Unique ID]=EARLIER(Data[Unique ID])&&(Data[Order Status]="Completed"||Data[Order Status]="Processing")))
First discount received = LOOKUPVALUE(Data[discount_total],[date_created],[First created date],[Unique ID],[Unique ID],[Order Status],"Completed")
Hope this helps.
Thanks, this works!!!
You are welcome.
Hi @Anonymous ,
can you please share the dataset here ? It wouldn't be possible to get it from the image ?
I may be missing something but I can't seem to attach a file.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
109 | |
98 | |
77 | |
66 | |
54 |
User | Count |
---|---|
144 | |
104 | |
100 | |
86 | |
64 |