Forum Discussion

TanzilHasan's avatar
TanzilHasan
Frequent Visitor
1 year ago
Solved

Group Customer by Order type

Hi All,    I have a data set that includes customer ID, order number, order date, and order type. The order type has three possible values: free, paid, and mixed. For example, a single customer may...
  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi TanzilHasan,

    Thanks for reaching out Microsoft fabric community forum.


    As per your query, follow the below steps to achieve you goal.

    I used the above data. I imported data into power query editor and in transform data i have done group by customer id and order type. 

    A separate table is created for each customer 

    Add custom column .use the below code in formula bar 

    Text.Combine(List.Distinct([Order Types][Order Type]), ", ") 

    Add another custom column by using the below code in formula bar:

    if Text.Contains([Custom], "Paid") and Text.Contains([Custom], "Free") and Text.Contains([Custom], "Mixed") then "All Three"
    else if Text.Contains([Custom], "Paid") and Text.Contains([Custom], "Free") then "Free and Paid"
    else if Text.Contains([Custom], "Paid") and Text.Contains([Custom], "Mixed") then "Paid and Mixed"
    else if Text.Contains([Custom], "Paid") then "Only Paid"
    else if Text.Contains([Custom], "Free") then "Only Free"
    else "Other"

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. 

    Thank you