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
Anonymous
Not applicable

Calculate the number of Comebacks

Hi,

I have a Case table with unique Case ID's and a Case Log table with works logs for each case : 
Case Table

idcase no   subject  created dateowner name
500DMS12      xyz    datetimezima
500TMS13      abc    datetimeelka

Case Log:

 

Case_cproxycase nocreated byStart_Date__cOffice__c   Queue_NameStatusCome Back2[calculated]
asvsaj500DMS12 10/28/2022 9:06location1  Client Service In Progress 
asbsat500DMS12 10/26/2022 1:33location1  Client Service In Progress 
sacbsn500DMS12 10/25/2022 6:23location1  Client Service In Progress 
safghj500DMS12 10/23/2022 22:54location1  Client Service In Progress 
sdacasa500DMS12 10/26/2022 22:58location2  Client Service In Progress 
ssasaccsa500DMS12 10/26/2022 20:09location2  Client Service In Progress 
scsZXxz500DMS12 10/22/2022 0:13location3  Client Service New 
xzccac500DMS12 10/26/2022 20:20location1  DCS - Data and series teamEscalatedYes
czxxzcxz500DMS12 10/26/2022 18:27location1  DCS - Data and series teamEscalatedYes
zxxz hgg500DMS12 10/25/2022 21:12location3  DCS - Data and series teamEscalatedYes
xzxczxcsd500DMS12 10/26/2022 19:33location1  DCS - Data and series teamEscalatedYes
xzxzxc500DMS12 10/26/2022 3:17location2  Client ServiceEscalated 
zxxzxzxz500DMS12 10/27/2022 3:00location4  DCS - Data and mani teamEscalatedYes
zxxzcxzc500DMS12 10/26/2022 20:23location1  DCS - Data and mani teamEscalatedYes
xzxzcxz500DMS12 10/24/2022 21:12location2  DCS - Data and mani teamEscalatedYes
xzxzczx500DMS12 10/27/2022 8:22location1  DCS - Data and mani teamEscalatedYes
zxcxzc500DMS12 11/11/2022 23:17location2  DCS - Data and mani teamEscalatedYes

So the case and case log are connect by 'Case'[ID] and 'Case Log'[Proxy] column by one to many. I want to get the case comeback for each case when it came to the department DCS and status not 'escalated' or 'assigned' or few more values . so i created the calculated column which prints "Yes" when the conditions satisfy but I want to skip the first "Yes" as it'

sthe first time it came to the DCS department. So i use the below code to substract 1 but in matrix it substract 1 from overall comebacks and not for unique cases.
Count of Come_Back_2 = if((COUNTA('Case Log'[Come Back])-1)<=0,BLANK(),(COUNTA('Case Log'[Come Back])-1))

 

 So all in all i get the count of comeback value but when i put it in table w.r.t the case owner it just substracts (1) from the whole count of comebacks. so if i have 2 cases for one owner and 7 comebacks for case1 and 6 for case 2 it gives me total count as 12 i.e 13 - 1. but i need is (7-1) + (6-1) i.e 11

Hope it is clear. 

Thanks for any help !!

1 ACCEPTED SOLUTION
ppm1
Solution Sage
Solution Sage

Please update your post with the additional data/information you shared via Private Message, so that others can potentially benefit from your scenario. Below is an updated measure expression that appears to do what you need. Please confirm.

ppm1_0-1670162566356.png

CaseBackCount =
SUMX (
    VALUES ( 'Case'[case no] ),
    VAR vCount =
        CALCULATE (
            COUNTROWS ( 'CaseLog' ),
            NOT ( 'CaseLog'[Status] IN { "new", "in progress" } )
                && SEARCH ( "dcs", 'CaseLog'[Queue_Name],, 0 ) > 0
        )
    RETURN
        IF ( ISBLANK ( vCount ), 0, vCount - 1 )
)

 

Pat

Microsoft Employee

View solution in original post

4 REPLIES 4
ppm1
Solution Sage
Solution Sage

Please update your post with the additional data/information you shared via Private Message, so that others can potentially benefit from your scenario. Below is an updated measure expression that appears to do what you need. Please confirm.

ppm1_0-1670162566356.png

CaseBackCount =
SUMX (
    VALUES ( 'Case'[case no] ),
    VAR vCount =
        CALCULATE (
            COUNTROWS ( 'CaseLog' ),
            NOT ( 'CaseLog'[Status] IN { "new", "in progress" } )
                && SEARCH ( "dcs", 'CaseLog'[Queue_Name],, 0 ) > 0
        )
    RETURN
        IF ( ISBLANK ( vCount ), 0, vCount - 1 )
)

 

Pat

Microsoft Employee
ppm1
Solution Sage
Solution Sage

Why are your using RANKX here? What about this measure?

 

= CALCULATE(COUNTROWS('tablename'), 'tablename'[yes/no col] = "Yes") - 1

 

Pat

 

Microsoft Employee
Anonymous
Not applicable


I got the yes/no column after this code. So if I use your measure it just gives me -1 for each case no in a table

it seems you expect a calculated column, try to create one with this:

CALCULATE(
    COUNTROWS(tablename),  ALLEXCEPT(tablename, tablename[case]),
    tablename[yes/no col] = "Yes"
) - 1

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.