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

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.

Reply
Anonymous
Not applicable

Help with formula for multiple criteria

Hi!

I am pretty new in power-bi and need help with a formula and logic for a customer analysis. Since I couldn't find any similar issue in the forum I try to explain my situation below.

 

The company I work for run 3 different brands, lets call them lens1, lens2, and lens3. What I now need to get a grip of is (1) how many customers as we have in each brand (witin the same market), (2) how many customers that belongs to more than one brand, and also (3) whithin which brand the latest purchase took place.

 

Sample data is attached below: 

Sales table

Brand_keymarket_keycustomer_keyorder_numberorder_datelatest_order_date
111123100109-jan-1810-dec-19
111123102010-dec-1910-dec-19
211123110005-jan-1705-jan-17
311123120020-jun-1820-jun-18
114125120111-jan-2011-jan-20
114126120212-jan-2012-jan-20
214125120502-feb-2002-feb-20
314127120610-mar-2010-mar-20
112128120710-mar-2010-mar-20
212129120810-jun-2010-jun-20
312129120910-jul-2010-jul-20
114130121010-aug-2010-aug-20
214130121111-aug-2011-aug-20
114131121212-aug-2012-aug-20
212132121310-jul-2010-jul-20
113133100510-aug-1710-jun-20
113133121510-jun-2010-jun-20
213133122005-jun-1905-jun-19
313133122511-mar-1911-mar-19

 

Brand table

Brand_keyBrand_name
1lens1
2lens2
3lens3

 

Market table

Market_keyMarket_NAME
11FINLAND
12DENMARK
13NORWAY
14SWEDEN

 

Customer table

CUSTOMER_KEYCUSTOMER_EMAIL
123123@gmail.com
125125@gmail.com
126126@gmail.com
127127@gmail.com
128128@gmail.com
129129@gmail.com
130130@gmail.com
131131@gmail.com
132132@gmail.com
133133@gmail.com

 

To be mention is that last order date within the sales table is a calculated column based brand, market, and customer key. The latest order date will always be max.

 

Expected output from sample data:

Total no customers in lens 1

7

Total no customers in lens 2

6

Total no customers in lens 3

4

Customers purchased in both lens1&lens2 (in same market)

4

Customers purchased in both lens1&lens3 (in same market)

2

Customers purchased in both lens2&lens3 (in same market)

3

Customer purchased in lens1&lens2 with latest purchase in lens1 (in same market)

2

Customer purchased in lens2&lens3 with latest purchase in lens2 (in same market)

1

Customer purchased in lens1&lens3 with latest purchase in lens1 (in same market)

2

 

Explanation in words 

The following three questions need to be answered:

 

(1) What is the total number of customers for each brand?

First I need to understand how many customers I actually have for each brand. The brand is here called lens1, lens2, lens3. 

 

(2) How many customers belongs to more than one brand?

When I know the answer of (1), I need to undertand how many customers that are customers/ have purchased from another brand as well. For example, no customer in lens1 & lens2 are in this sample data 4. 

 

(3) Within which took the latest purchase place?

When knowing which customers that belongs to more than one brand (2), I need to undertand where the latest purchase took place. For example, customers in both lens1 &lens2 where the latest purchase was in lens1 is in the sample data 2. 

 

Hope that some of you can solve this - Thanks in advance!

3 REPLIES 3
v-lili6-msft
Community Support
Community Support

hi  @Anonymous 

and 'Previous_Brand'[BRAND_NAME] is a duplicated tables with same dimensions as'Brand'[BRAND_NAME].

why you need two tables for two brand? you'd better keep it one table.

 

Sample PBIX file and expected output would help tremendously.

 

Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Greg_Deckler
Super User
Super User

@Anonymous - Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
amitchandak
Super User
Super User

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.