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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Laufer_Israel
Helper I
Helper I

count duplicate dates per Customer ID

Hi all,

I have the below data:

ID     Date     Order Type

1      09/12      regular

1      09/13      regular

1      09/14      regular

1      09/15      regular

1      09/15       digital

 

The ID is a customer ID which I have 7,000 customers in my data.

I would like to count the duplicate dates within every customer (ID) AND only if one of the duplicate orders are digital.

i.e. if I have two records at the same day but both are regular or both are digital this is irelevant.

 

At the end, the result I'm looking for on the above example is: there is one day with two orders and one of them are digital.

 

Can someone help please?

Many thanks in advance!

1 ACCEPTED SOLUTION

Hi @Laufer_Israel ,

Based on your description, you can create this measrue to count:

Count =
VAR tab =
    FILTER (
        ALL ( 'Table' ),
        CALCULATE (
            COUNTROWS ( 'Table' ),
            FILTER (
                ALL ( 'Table' ),
                'Table'[ID] = EARLIER ( 'Table'[ID] )
                    && 'Table'[Date] = EARLIER ( 'Table'[Date] )
            )
        ) >= 2
    )
RETURN
    COUNTX (
        FILTER (
            tab,
            [ID]
                IN DISTINCT ( 'Table'[ID] )
                    && [Date]
                        IN DISTINCT ( 'Table'[Date] )
                            && [Order Type] = "regular"
        ),
        [Order Type]
    )

tb.pngre.png

Attached a sample file in the below, hopes to help you.

 

Best Regards,
Community Support Team _ Yingjie Li
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

5 REPLIES 5
Laufer_Israel
Helper I
Helper I

Can someone help?

Hi @Laufer_Israel ,

Based on your description, you can create this measrue to count:

Count =
VAR tab =
    FILTER (
        ALL ( 'Table' ),
        CALCULATE (
            COUNTROWS ( 'Table' ),
            FILTER (
                ALL ( 'Table' ),
                'Table'[ID] = EARLIER ( 'Table'[ID] )
                    && 'Table'[Date] = EARLIER ( 'Table'[Date] )
            )
        ) >= 2
    )
RETURN
    COUNTX (
        FILTER (
            tab,
            [ID]
                IN DISTINCT ( 'Table'[ID] )
                    && [Date]
                        IN DISTINCT ( 'Table'[Date] )
                            && [Order Type] = "regular"
        ),
        [Order Type]
    )

tb.pngre.png

Attached a sample file in the below, hopes to help you.

 

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Laufer_Israel
Helper I
Helper I

I will try to be more clear:

Regular order means that the customer ordered stock directly from the sales man in a specific day. a Digital order is an order that the customer conducted in advance (for a specific date).

When I see in the data two orders for the same day when one is regular and the other is digital it means that the digital order wasn't anoght for the customer and he asked the sales man for an immidiate additional order.

 

Thats what I'm looking for - I'm trying to understand how many regular orders apears at the same day of the digital order.

amitchandak
Super User
Super User

@Laufer_Israel , expected output is not clear

 

A measure like this

sumx(Summarize(Table, Table[ID], "_1", distinctcount(Table[Date])),[_1]-1)

As I mentioned, I have 7,000 customers. every customer conducting an order which can be regular or digital order..

What I would like to know is to identify the number of events (count of days) that each customer conducted both regular and digital order at the same day.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.