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
pstanek
Post Patron
Post Patron

Number of customers

Hi I have table with these columns Shop , customer card, data of shopping , revenue, I have some idea how to calculate date of the cfist purchase, but I want to calculate  for some date , number of customers who  who made the first purchace that day  . Do you have any idea.  how to do it?

9 REPLIES 9
v-ljerr-msft
Employee
Employee

Hi @pstanek,

 

I am wondering if the formula(untested) below works in your scenario? Smiley Happy

measure =
VAR firstCustomer =
    FIRSTNONBLANK ( 'Table1'[Customer], 1 )
RETURN
    CALCULATE (
        COUNTROWS ( 'Table1' ),
        FILTER ( 'Table1', 'Table1'[Customer] = firstCustomer )
    )

 

Regards

I  think , it will find only find first customer, not first purchases.

 

Column customer is blank, or there is the customer card number.

 

If date is  the oldest for certain customer card number, it means that date the first purchase was  made the  by that customer.

 

For certain date I want to count customer card  numbers( unique) that hasn´t appear before that date.

 

It means  They made the first purchases that date .

 I was right, function summarize is not available. I will have to find another solution.

Hi I create example.Capture.PNG

Result of measure should be 2 for 29.05.2017, because  there we have  customer card 2 nad 7  made the first purchases. For 28.05.2017 result should be 1 , because only customer card 4 made the first purchase.

 

I need solution that be available for direct query.

Hi @pstanek,

 

Based on my test, the formula below should work in your scenario. Smiley Happy

Measure =
CALCULATE (
    DISTINCTCOUNT ( Table1[Custom Card] ),
    FILTER (
        Table1,
        Table1[Custom Card] <> BLANK ()
            && NOT (
                CONTAINS (
                    FILTER ( ALL ( Table1 ), Table1[Shopping Date] < MAX ( Table1[Shopping Date] ) ),
                    Table1[Custom Card], Table1[Custom Card]
                )
            )
    )
)

r3.PNG

 

Regards

only one error in measure ,CONTAINS is not supported by DirectQuery.

Hi @pstanek,

 

Based on my test, the CONTAINS function should be supported in DirectQuery mode.

 

Have you enabled the 'Allow unrestricted measures in DirectQuery mode' option under File > Options > DirectQuerySmiley Happy

 

dq1.PNG

 

Regards

Greg_Deckler
Super User
Super User

You could create a measure that did a SUMMARIZE of your table filtered by the date that grouped by customer and had an expression that was a COUNT?


@ 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...

I am not sure it can work within Direct Query. I thought functions (with result in form of table) are not supported in that mode

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.