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
DeeMag
Helper II
Helper II

Can some DAX expert help me on below requirement please

Hi all,

 

DeeMag_0-1631276114973.png

Date Set : As given above, I have a dataset which has callers and dates on which they called.

 

Requirement : To find wherther the call by caller is unique or not in when checked in past 3 days.

 

example : on 3rd Sep caller 1021 has called, if you observe in the screen shot, there were no calls from 1021 in the past consecutive 3 days, so it should be marked as unique. This should be checked for all days for all the callers.

 If you need more explanation on this, let me know.

 

I hope someone can help me on this please an d appreciate your help.

 

Thank you.

 

2 ACCEPTED SOLUTIONS

Hi @DeeMag ,

 

Based on your data, you can use the following calc column to identity the type of call

 

 

Call Type = 
var _caller_id = 'Table'[Caller]
var _curr_date = 'Table'[Date]
var _prior_max_date = CALCULATE(MAX('Table'[Date]), FILTER(all('Table'), 'Table'[Date]<_curr_date&& 'Table'[Caller] = _caller_id))
var _date_diff = DATEDIFF(_prior_max_date,_curr_date, DAY)
return 
if(_date_diff<=3&&NOT(ISBLANK(_date_diff)), "repeat", "unique")

 

 

Thanks,



I hope this helps,
Richard

Did I answer your question? Mark my post as a solution! Kudos Appreciated!

Proud to be a Super User!


View solution in original post

Hi @DeeMag,

Happy to help!



I hope this helps,
Richard

Did I answer your question? Mark my post as a solution! Kudos Appreciated!

Proud to be a Super User!


View solution in original post

12 REPLIES 12
Greg_Deckler
Super User
Super User

@DeeMag Is that how your data looks in your model? If so, I would unpivot your date columns and then the issue should be straight-forward. 

 

Sorry, having trouble following, can you post sample data as text and expected output?
Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Hi Greg,

Thanks for getting back.

actually the data does not look like that. I have download and made it look that way for easier understanding of logic.

The data come from a database and on data sheet it looks like this and has other columns as well.

DeeMag_0-1631280123498.png

 

Regards,

Deepthi

 

 

 

Hi @DeeMag,

 

Can you please provide the data in a table and not an image, makes the process of delivering a solution much easier.

 

Thanks,



I hope this helps,
Richard

Did I answer your question? Mark my post as a solution! Kudos Appreciated!

Proud to be a Super User!


Hi Richard,

 

Is there any way to upload table?

Regards,

Hi Greg,

I downloaded this report to excel from Power BI and just Pivoted it by counting callers by day.

Ignore Queue column.

DeeMag_0-1631280765007.png

 

QueueCallerDateTotal calls
Abandoned238916/08/2021 00:001
Abandoned793317/08/2021 00:001
Abandoned353418/08/2021 00:002
P302353418/08/2021 00:001
Abandoned102118/08/2021 00:002
Abandoned102123/08/2021 00:001
Abandoned102223/08/2021 00:003
Abandoned102323/08/2021 00:004
Abandoned106024/08/2021 00:002
Abandoned748324/08/2021 00:001
P360238924/08/2021 00:001
Abandoned102124/08/2021 00:002
Abandoned747625/08/2021 00:002
Abandoned176125/08/2021 00:003
Abandoned155725/08/2021 00:002
Abandoned409225/08/2021 00:001
Abandoned793325/08/2021 00:001
Abandoned176126/08/2021 00:001
Abandoned748327/08/2021 00:008
Abandoned176127/08/2021 00:001
Abandoned70231/08/2021 00:003
Abandoned238931/08/2021 00:001
P360238931/08/2021 00:001
Abandoned493631/08/2021 00:003
P301493631/08/2021 00:001
P301845402/09/2021 00:001
Abandoned102302/09/2021 00:001
Abandoned102103/09/2021 00:007
Abandoned102203/09/2021 00:004
Abandoned102303/09/2021 00:003

actually total calls  will be 1, 2,3 etc not in the format you see.

Hi @DeeMag ,

 

Based on your data, you can use the following calc column to identity the type of call

 

 

Call Type = 
var _caller_id = 'Table'[Caller]
var _curr_date = 'Table'[Date]
var _prior_max_date = CALCULATE(MAX('Table'[Date]), FILTER(all('Table'), 'Table'[Date]<_curr_date&& 'Table'[Caller] = _caller_id))
var _date_diff = DATEDIFF(_prior_max_date,_curr_date, DAY)
return 
if(_date_diff<=3&&NOT(ISBLANK(_date_diff)), "repeat", "unique")

 

 

Thanks,



I hope this helps,
Richard

Did I answer your question? Mark my post as a solution! Kudos Appreciated!

Proud to be a Super User!


Excellent, Thank you so much, it works!!

Hi @DeeMag,

Happy to help!



I hope this helps,
Richard

Did I answer your question? Mark my post as a solution! Kudos Appreciated!

Proud to be a Super User!


Hi Richard,

 

Earlier you helped on this request, Thanks for that. 

But, I need a small tweak on existing code please.

If the call appears on same day, 1st call should be unique and other calls on same day should be repeat. can you please help on this.

DeeMag_0-1633598525751.png

Let me know if you need more details.

Thank you, appreciate your help on this.

Hi @DeeMag,

 

How do we Know which is the first call? the Date does not provide a call time?



I hope this helps,
Richard

Did I answer your question? Mark my post as a solution! Kudos Appreciated!

Proud to be a Super User!


Thanks much Richard, I will try it and update you on this.

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.