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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

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
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.