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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.