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
Nagin
Frequent Visitor

Calculated Column - Counting Duplicates in a Month

Hi Everyone,

 

I am trying to create a calculated column to flag the number of duplicates, where if the patient "[NHS_Number_Nat_Pseud]"

has called "[EMAS Call Connect Date]" more than 5 times within a month, I have created the following but to no success

 

EMAS Reattendance Month =
VAR Numberofcalls =
CALCULATE(
COUNT(EMAS[NHS_Number_Nat_Pseud]),FILTER
(ALL(EMAS),EMAS[NHS_Number_Nat_Pseud]= EARLIER(EMAS[NHS_Number_Nat_Pseud]) && month(EMAS[EMAS Call Connect Date])=
MONTH(EARLIER(EMAS[EMAS Call Connect Date])
&& YEAR(EMAS[EMAS Call Connect Date])=
YEAR(EARLIER(EMAS[EMAS Call Connect Date])
))))
RETURN
IF (Numberofcalls <=4 && NOT(ISBLANK(Numberofcalls)), " No", IF (ISBLANK(Numberofcalls),"", " Yes") )

 

Any help on this would be much appricated 

 

Thanks

 

Nagin

3 ACCEPTED SOLUTIONS
tamerj1
Super User
Super User

Hi @Nagin 

please try

EMAS Reattendance Month =
VAR CurrentMonth =
    MONTH ( EMAS[EMAS Call Connect Date] )
VAR CurrentYear =
    YEAR ( EMAS[EMAS Call Connect Date] )
VAR CurrentIDtable =
    CALCULATETABLE ( EMAS, ALLEXCEPT ( EMAS, EMAS[NHS_Number_Nat_Pseud] ) )
VAR FilteredTable =
    FILTER (
        CurrentIDtable,
        EMAS[NHS_Number_Nat_Pseud] <> BLANK ()
            && MONTH ( EMAS[NHS_Number_Nat_Pseud] ) = CurrentMonth
            && YEAR ( EMAS[NHS_Number_Nat_Pseud] ) = CurrentYear
    )
RETURN
    IF ( COUNTROWS ( FilteredTable ) > 5, "Yes", "No" )

 

View solution in original post

Nagin
Frequent Visitor

Hi @tamerj1 

 

Thanks for this worked perfectly

View solution in original post

@Nagin 
Great to hear that!
Kindly conisder marking my reply as acceptable solution

View solution in original post

3 REPLIES 3
tamerj1
Super User
Super User

Hi @Nagin 

please try

EMAS Reattendance Month =
VAR CurrentMonth =
    MONTH ( EMAS[EMAS Call Connect Date] )
VAR CurrentYear =
    YEAR ( EMAS[EMAS Call Connect Date] )
VAR CurrentIDtable =
    CALCULATETABLE ( EMAS, ALLEXCEPT ( EMAS, EMAS[NHS_Number_Nat_Pseud] ) )
VAR FilteredTable =
    FILTER (
        CurrentIDtable,
        EMAS[NHS_Number_Nat_Pseud] <> BLANK ()
            && MONTH ( EMAS[NHS_Number_Nat_Pseud] ) = CurrentMonth
            && YEAR ( EMAS[NHS_Number_Nat_Pseud] ) = CurrentYear
    )
RETURN
    IF ( COUNTROWS ( FilteredTable ) > 5, "Yes", "No" )

 

Nagin
Frequent Visitor

Hi @tamerj1 

 

Thanks for this worked perfectly

@Nagin 
Great to hear that!
Kindly conisder marking my reply as acceptable solution

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.

Top Solution Authors