Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
Hello everyone,
I have a dataset that contains a lot of transaction, each of them detailed. This means that there is a row for every product within an order, like this:
Order | Sku Name |
1 | Product A |
1 | Product B |
2 | Donation A |
3 | Product C |
3 | Donation B |
4 | Donation A |
4 | Donation B |
Now I'm trying to create a calculated column that could help me identify the Type of order like this:
Order | Sku Name | Type of Order |
1 | Product A | Sales |
1 | Product B | Sales |
2 | Donation | Donation |
3 | Product C | Mixed |
3 | Donation | Mixed |
4 | Donation | Donation |
4 | Donation | Donation |
I have been trying using EARLIER but I can only get Sales and Donations identified, I don't know how to identify the orders that contains both Donations and normal Products.
Thank you!!
Solved! Go to Solution.
@Grevatious Usually in scenarios like this you have a product table with a unique record and have relationship with sales, and that product table will have type of product like Donatoins or Sales
Anyhow, add following two columns in your table and it should work.
Type = IF ( CONTAINSSTRING( 'Table'[Sku Name], "Donation" ), "Donation", "Sales" )
Order Type =
VAR __c = CALCULATETABLE( VALUES ( 'Table'[Type] ), ALLEXCEPT('Table', 'Table'[Order] ) )
RETURN
SWITCH ( TRUE(),
COUNTROWS( __c ) > 1, "Mixed",
__c
)
First column is to get type of the product, if this information is in product table then it can be used from there.
Would appreciate Kudos 🙂 if my solution helped.
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.
Try a new column like
New column =
var _all = countx(filter(table,table[Order]=earlier(Table[Order])),table[Order])
var _sales = countx(filter(table,table[Order]=earlier(Table[Order]) && [Type of Order] = "Sales"),table[Order])
var _don = countx(filter(table,table[Order]=earlier(Table[Order]) && [Type of Order] = "Donation"),table[Order])
return
switch(true(),
_all =_sales , "Sales",
_all =_don , "Donation",
"Mixed"
)
@Grevatious Usually in scenarios like this you have a product table with a unique record and have relationship with sales, and that product table will have type of product like Donatoins or Sales
Anyhow, add following two columns in your table and it should work.
Type = IF ( CONTAINSSTRING( 'Table'[Sku Name], "Donation" ), "Donation", "Sales" )
Order Type =
VAR __c = CALCULATETABLE( VALUES ( 'Table'[Type] ), ALLEXCEPT('Table', 'Table'[Order] ) )
RETURN
SWITCH ( TRUE(),
COUNTROWS( __c ) > 1, "Mixed",
__c
)
First column is to get type of the product, if this information is in product table then it can be used from there.
Would appreciate Kudos 🙂 if my solution helped.
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.
User | Count |
---|---|
139 | |
113 | |
103 | |
73 | |
63 |
User | Count |
---|---|
135 | |
126 | |
110 | |
70 | |
61 |