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

Filter companies in one table (with multiple entries)

Hey,

 

i have a table with company names in row 1, a year in row 2 and sales in row 3. The sales sum indicates the sales for that specific cutomer in that year.

 

Customer 1201810.000,- $
Customer 2201912.000,- $
Customer 1201913.000,- $
Customer 320209.000,- $

 

I want to find out, which customer had sales this year (and how much) but didnt' have any sales the last 2 years (= new customer).

 

I'm currently stuck, at the point, that i have the same customer name multiple times in the same table. so all my filter, group by attemps etc. failed.

 

Thank you for any tip 🙂

1 ACCEPTED SOLUTION
v-robertq-msft
Community Support
Community Support

Hi, @Anonymous 

According to your description, you can follow my steps:

  1. Create a calculated column:
Flag =
var _year='Table'[year]
var _company='Table'[company name]
return
if(
    (CALCULATE(
        MAX([sales ]),
        FILTER('Table',
        'Table'[year]=_year-2
        &&
        'Table'[company name]=_company))>0
    ||
    CALCULATE(
        MAX([sales ]),
        FILTER('Table',
        'Table'[year]=_year-1
        &&
        'Table'[company name]=_company))>0)
    &&
    [sales ]>0,
    0,
    1
)
  1. Create a calculated table:
New customer =
FILTER('Table',
[year]=YEAR(TODAY())
&&
'Table'[Flag]=1)

And you can get what you want, like this:

v-robertq-msft_0-1605147402398.png

 

You can download my test pbix file here

 

Best Regards,

Community Support Team _Robert Qin

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

View solution in original post

3 REPLIES 3
v-robertq-msft
Community Support
Community Support

Hi, @Anonymous 

According to your description, you can follow my steps:

  1. Create a calculated column:
Flag =
var _year='Table'[year]
var _company='Table'[company name]
return
if(
    (CALCULATE(
        MAX([sales ]),
        FILTER('Table',
        'Table'[year]=_year-2
        &&
        'Table'[company name]=_company))>0
    ||
    CALCULATE(
        MAX([sales ]),
        FILTER('Table',
        'Table'[year]=_year-1
        &&
        'Table'[company name]=_company))>0)
    &&
    [sales ]>0,
    0,
    1
)
  1. Create a calculated table:
New customer =
FILTER('Table',
[year]=YEAR(TODAY())
&&
'Table'[Flag]=1)

And you can get what you want, like this:

v-robertq-msft_0-1605147402398.png

 

You can download my test pbix file here

 

Best Regards,

Community Support Team _Robert Qin

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

Anonymous
Not applicable

Hey @v-robertq-msft ,

your solution works great! Thank you!

Now i have to learn, what you exactly did 🙂

lbendlin
Super User
Super User

Take it step by step

 

- for each customer and year find the value. 

- find the latest previous year with a value for the same customer

- if found nothing, or if the year is at least 2 years earlier than the current one, flag the entry as new customer.

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.