cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
BIBITARIFA
Helper I
Helper I

CALCULATE A NEW COLUMN WITH FUNCTION IF

Hi everyone! 

 

I need to create a new column that: Return 0 if the same person calls again and 10 minutes have not passed since the first call.  Otherwise, return 1.

I attached an example to understand it better:

Captura.PNG

Hope someone can help me. 

 

Cheers! 

 

1 ACCEPTED SOLUTION

@BIBITARIFA , Try like

 

In 10 Min = var _last = maxx(FILTER('DATOS CALL CENTER (2)', 'DATOS CALL CENTER (2)'[Cola] = EARLIER([Cola]) && [Rank] = EARLIER([Rank]) -1),[Fecha]) var _secondLast = maxx(FILTER('DATOS CALL CENTER (2)', 'DATOS CALL CENTER (2)'[Cola] = EARLIER([Cola]) && [Rank] = EARLIER([Rank]) -2),[Fecha]) var _diff1 = DATEDIFF(_last, [Fecha],SECOND)/60 var _diff2 = DATEDIFF(_secondLast, [Fecha],SECOND)/60 var _diff3 = DATEDIFF(_secondLast, _last,SECOND)/60 return SWITCH(TRUE(), ISBLANK(_diff1) , 1 , _diff1 >=10, 1, _diff3>10 && _diff1 <10, 0, _diff1<10 && _diff2 >10 && _diff3< 10 , 1 , 0 )

View solution in original post

5 REPLIES 5
jgeddes
Solution Sage
Solution Sage

You can create a calculated column

Recalls = 

var _firstCallTime =

CALCULATE(

    MIN('yourTable'[Time]),

    ALLEXCEPT('yourTable', 'yourTable'[Calls])

)

var _elapsedTime =

[Time] - _firstCallTime

var _elapsedTimeFormatted =

(HOUR(_elapsedTime)*60) + MINUTE(_elapsedTime)

Return

SWITCH(

    TRUE(),

    [Time] = _firstCallTime, 1,

    _elapsedTimeFormatted < 10, 0,

    1

)

And you would end up with

jgeddes_0-1669672009344.png

 

@jgeddes thanks for answering. I tried your dax code but isn't working. I don't know why. 

I'm gonna share with you my file: https://drive.google.com/file/d/1BzCJ-3gKAEVkkIHtjpN4LnWqRBUR0cQb/view?usp=share_link where "Cola" = Calls, "Tiempo inicio" = Time. 

Thanks

@BIBITARIFA , Try like

 

In 10 Min = var _last = maxx(FILTER('DATOS CALL CENTER (2)', 'DATOS CALL CENTER (2)'[Cola] = EARLIER([Cola]) && [Rank] = EARLIER([Rank]) -1),[Fecha]) var _secondLast = maxx(FILTER('DATOS CALL CENTER (2)', 'DATOS CALL CENTER (2)'[Cola] = EARLIER([Cola]) && [Rank] = EARLIER([Rank]) -2),[Fecha]) var _diff1 = DATEDIFF(_last, [Fecha],SECOND)/60 var _diff2 = DATEDIFF(_secondLast, [Fecha],SECOND)/60 var _diff3 = DATEDIFF(_secondLast, _last,SECOND)/60 return SWITCH(TRUE(), ISBLANK(_diff1) , 1 , _diff1 >=10, 1, _diff3>10 && _diff1 <10, 0, _diff1<10 && _diff2 >10 && _diff3< 10 , 1 , 0 )

@BIBITARIFA , check if this can help

Check if this solution can work.

new column =

var _max = maxx(filter( Table, [calls] = earlier([call]) && [Time] <earlier(Time) ), [Time])

return if( isblank(_max) || datediff(_max, [Time], second)/60 > 10, 1 ,0)

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors