Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply

Customer Segmentation - based on order rank 1 or rank 2

Hi,

I need help! 

So, in my orders table, I created two calculated columns - 

_____Redeemer 1 =

VAR CustomerID = orders[customer_id]
VAR _HC = orders[with HC]


RETURN

IF( CustomerID = orders[customer_id] &&
    _HC = "Yes" &&
    orders[_Order Ranking] = 1 ,
    "REDEEMER" ,
    ""
   )

and

_____Redeemer 2 =

VAR CustomerID = orders[customer_id]
VAR _HC = orders[with HC]


RETURN

IF( CustomerID = orders[customer_id] &&
    _HC = "Yes" &&
    orders[_Order Ranking] = 2 ,
    "REDEEMER" ,
    ""
   )


What I am trying to achieve here is: 

1. Identify which order the customer sent an HC bag- in the first or second order. 
2. Then, marked the unique customer REDEEMER1, REDEEMER2, NON-REDEEMER
REDEEMER1 is if he/she submitted an HCbag in the first order or REDEEMER1 
REDEEMER2 is if he/she submitted an HCBag in the second order but no HC bag in the first order.
Lastly, if no HC bag in both the first or second order, Tag him as "NON-REDEEMER".

Ultimately, I need to create a stacked column chart where my x-axis is the order ranking, the y-axis is the distinct count of customer_id, having a legend REDEEMER1, REDEEMER2, and NON-REDEEMER.  In the chart, REDEEMER2 should only appear from order_rank 2 onwards, there shouldn't be any REDEEMER2 in Order rank 1. 
Screenshot 2023-05-14 235140.pngScreenshot 2023-05-14 235205.png


For some reason, I cannot add the pbix file here. I can share it to anyone who is willing to help me out. THank you.






4 REPLIES 4
amitchandak
Super User
Super User

@Andrew_na_lang , Try a new column like

 

var _max = maxx(filter(orders, orders[customer_id] = earlier(orders[customer_id]) && orders[with HC] ="Yes" ), orders[_Order Ranking])
return
Switch(true(),
_max =1, "REDEEMER 1",
_max =2, "REDEEMER 2",
"NON-REDEEMER")

 

If this does not help
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

@amitchandak it didn't work. For some reason, I cannot paste the pbix file here. How can I share it to you?

Screenshot 2023-05-15 092324.png

Screenshot 2023-05-15 092453.png

  

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.