Forum Discussion

TerenceM's avatar
TerenceM
Frequent Visitor
4 years ago
Solved

How can I determine whether an order is placed by VIP with VIP history table

Hello, 

I have done my research but couldn't find any similar cases.

 

My problem is

 

I have two tables, one is the sales table

Order idCustomer IDOrder DateSales Region
1123456782020-11-22HK
2234567892020-12-23US

 

Another one is the VIP History Table

Customer IDVIP Start DateVIP End DateType of VIP
123456782019-01-012020-01-01VIP
123456782021-01-012022-01-01VIP
234567892020-02-012021-02-01VVIP

 

What I want to do is to determine whether the order is purchased within the VIP period

So for the first order, it's not a VIP order, because the order date does not fall in the neither VIP period of the customer 12345678

On the other hand, the second order is a VVIP order, because the order date fall into the VVIP period of the customer 23456789.

 

Thank you in advance!

 

Best Regards,

Terence

  • TerenceM , You can get that value in first table and then check for it

     

    a new column in the first table =

    maxx(filter(VIP, VIP{Customer ID] = Sales[Customer ID] && Sales[Order Date] >= VIP[Start Date] && Sales[Order Date]<= VIP[End Date]) , VIP[TYPE of VIP] )

2 Replies

  • TerenceM , You can get that value in first table and then check for it

     

    a new column in the first table =

    maxx(filter(VIP, VIP{Customer ID] = Sales[Customer ID] && Sales[Order Date] >= VIP[Start Date] && Sales[Order Date]<= VIP[End Date]) , VIP[TYPE of VIP] )

  • TerenceM's avatar
    TerenceM
    Frequent Visitor

    Thank you very much for your prompt reply! It works!