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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

New customers per department

Hi,

 

It's quite a basic question but I cannot come out with any solution. I need to calculate numer of new customers in 2020 per department. Additional requirement is that customer is new if he has not had any service delivered for the last 5 years. 

 

So in this case:

Department 2 should have 2 new customers(A and B).

Department 1 should have 3 new customers(because the last time A had something delivered was more than 5 years ago).

 

Screen.PNG

The problem that I experience is that my fact table is much bigger and I am running out of memory when I am trying some more demanding calculations ( like this one https://community.powerbi.com/t5/Desktop/new-customers-in-a-selected-period/m-p/307926#M136283 ). 

 

I have also tried to create a measure like that:

 

 

#Measure:=COUNTROWS (
    FILTER (
        ADDCOLUMNS (
            VALUES ( Fact[CustomerID] ),
            "PreviousDeliveries",
                CALCULATE(
                    COUNTROWS ( Fact),
                    FILTER(
                        ALL( Dato),
                        Dato[Year] <=2020
                    
                )
        )),
        ISBLANK ( [PreviousDeliveries] )
    )
)

 

 

 

 And then creating a flag on my fact table:

 

 

=IF(CALCULATE([#Measure])>0,"Yes","No")

 

 

However I could not put it together either.

 

I am very new to dax so any help would be appreciated.

 

Thank you in advance!

 

2 REPLIES 2
v-yiruan-msft
Community Support
Community Support

Hi @Anonymous,

Whether you already got the solution?

 

Best Regards

Rena

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

I will prefer to have a column in the table which tells me the last delivery date. Rest can be calculated on top it

Last Deilvery Date = maxx(filter(Fact,  Fact[CustomerID]=earlier( Fact[CustomerID]) && Fact[Deilvery Date]<earlier(Fact[Deilvery Date])),Fact[Deilvery Date])

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution.
In case it does not help, please provide additional information and mark me with @

Thanks. My Recent Blogs -Decoding Direct Query - Time Intelligence, Winner Coloring on MAP, HR Analytics, Power BI Working with Non-Standard TimeAnd Comparing Data Across Date Ranges
Proud to be a Datanaut Connect on Linkedin

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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