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
decarsul
Helper IV
Helper IV

Identifier unique or not, per row, powerpivot

Good day all,

 

Hopefully this post is saved  . . .

In the past, i've visitted these forums and got an answer to my question, so i'm having hopes!

 

I have a dataset in which i want to add a column to see if a customer id is unique or not per row.

This so i can count how many unique customers have called and to create an average on how many customers call multiple times within a time period of 5 days.

 

The datatable i have:

call idcontact datecustomerid
11-7-2020100
22-7-2020102
38-7-2020100
42-7-2020104
520-7-2020120
621-7-2020180
722-7-2020180
831-7-2020258
928-7-20206524
1023-7-2020619663

 

The result i need:

call idcontact datecustomeridRepeat 5 days
11-7-20201000
22-7-20201020
38-7-20201000
42-7-20201040
520-7-20201200
621-7-20201801
722-7-20201801
831-7-20202580
928-7-202065240
1023-7-20206196630

 

I have tried the following code, which did not work:

Calculate(distinctcount(callid);groupby(table;customerid))

 

Alternatively i just want a value true or false per row, to see if that customer has called multipletimes within the time period.

The timeperiod filter has not been added to above tried formula, as i was figuring out the first part and i could just add an if statement to it to make it a true/false value.

 

Hoping you guys have some suggestions!

 

p.s. i'm hoping to avoid creating an facts table with unique customer id's and a count of callid's

1 ACCEPTED SOLUTION
Icey
Community Support
Community Support

Hi @decarsul ,

 

How about creating a measure like so:

Measure =
VAR thisdate =
    MAX ( 'Table'[contact date] )
RETURN
    CALCULATE (
        COUNT ( 'Table'[call id] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            'Table'[customerid] = MAX ( 'Table'[customerid] )
                && 'Table'[contact date] >= thisdate - 4
                && 'Table'[contact date] <= MAX ( 'Table'[contact date] )
        )
    )

repeat.PNG

 

Then, you can find that if [Measure]>1, it means that this "customerid" has called once in previous 5 days.

 

And you can also create the measure like so:

Is Repeated in previous 5 days = 
VAR thisdate =
    MAX ( 'Table'[contact date] )
VAR Count_ =
    CALCULATE (
        COUNT ( 'Table'[call id] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            'Table'[customerid] = MAX ( 'Table'[customerid] )
                && 'Table'[contact date] >= thisdate - 4
                && 'Table'[contact date] <= MAX ( 'Table'[contact date] )
        )
    )
RETURN
    IF ( Count_ > 1, "True", "False" )

repeat2.PNG

 

 

 

Best Regards,

Icey

 

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
Icey
Community Support
Community Support

Hi @decarsul ,

 

How about creating a measure like so:

Measure =
VAR thisdate =
    MAX ( 'Table'[contact date] )
RETURN
    CALCULATE (
        COUNT ( 'Table'[call id] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            'Table'[customerid] = MAX ( 'Table'[customerid] )
                && 'Table'[contact date] >= thisdate - 4
                && 'Table'[contact date] <= MAX ( 'Table'[contact date] )
        )
    )

repeat.PNG

 

Then, you can find that if [Measure]>1, it means that this "customerid" has called once in previous 5 days.

 

And you can also create the measure like so:

Is Repeated in previous 5 days = 
VAR thisdate =
    MAX ( 'Table'[contact date] )
VAR Count_ =
    CALCULATE (
        COUNT ( 'Table'[call id] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            'Table'[customerid] = MAX ( 'Table'[customerid] )
                && 'Table'[contact date] >= thisdate - 4
                && 'Table'[contact date] <= MAX ( 'Table'[contact date] )
        )
    )
RETURN
    IF ( Count_ > 1, "True", "False" )

repeat2.PNG

 

 

 

Best Regards,

Icey

 

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

Great suggestion, let me tinker with that.

This will however cause me not to be able to use this in an historical sence.

 

As in, i won't be able to plot a count on the calendar dimension i'm planning to use in the future.

 

p.s. and not related, any idea why i keep getting notifications in spanish?

Icey
Community Support
Community Support

Hi @decarsul ,

 

If you want to use a calendar dimension, try this:

Is Repeated in previous 5 days 2 =
VAR thisdate =
    MAX ( 'Calendar'[Date] )
VAR Customer_ =
    MAX ( 'Table'[customerid] )
VAR Count_ =
    CALCULATE (
        COUNT ( 'Table'[call id] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[customerid] = Customer_
                && 'Table'[contact date] >= thisdate - 4
                && 'Table'[contact date] <= thisdate
        )
    )
RETURN
    IF ( Count_ > 1, "True", "False" )

repeat3.PNG

 

In addition, I don't know how to disable Spanish notifications. I meet the issue, too.☹️

 

 

Best Regards,

Icey

 

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

Allright,

 

Me and colleague did some tinkering, haven't looked at the 2nd option yet.

We used the first code, than we added a calculated column IF(is repeated=1;1;0) 

This generates a correct colum with true or falses which i can then use to plot on calendar and the likes.

 

Will check additional code to see if we can enhance performance, but in essence issue is solved. thanks!

decarsul
Helper IV
Helper IV

As a reference.

I would write this in OBIEE as follows:

 

Count(distinct 'table'.'callid' by 'table'.'customerid')

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.