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
Jorgast
Resolver II
Resolver II

Count of Cases based on Billing

Hello Power BI Community,

I have been tasked with finding customer calls in relation to when their bill was generated.

What i want to know is the number of cases created within 90days starting from the Invoice Date. Can someone help?

 

I have 3 tables

Invoice Table / Case Table / Date Table.

The Date table is joined to the Invoice table in the Invoice Created Date

The Date table is joined to the case table in the Created Date

 

I have tried the following options and haven't gotten anywhere

1. Calculate(Count(Case number), 'Case Table'[Account Number] = 'Invoice Table' [Account Number], DateDiff('Case Table'[Created Date] , 'Invoice Table' [Invoice Created Date], DAY) <= 90

2. CountRows(Filter( 'Case Table', Datediff(DateDiff('Case Table'[Created Date] , 'Invoice Table' [Invoice Created Date], DAY) <= 90)

 

INVOICE

Account NumberCustomer NameInvoice Created DateInvoice Due DateLast PaymentAmount OwedGeneratedCases submitted Column Results
3000James Bond2/1/20213/1/20211/15/2021100.00Auto0
3001Dr Evil2/1/20213/1/20211/15/2021100.00Manual4
3002Thanos2/1/20213/1/20211/15/2021100.00Auto1
3003Dr Doom2/1/20213/1/20211/15/2021100.00Auto1
3004Dr Octopus2/1/20213/1/20211/15/2021100.00Auto1
3005Spiderman2/1/20213/1/20211/15/2021100.00Auto1
3001Dr Evil2/15/20213/1/20211/15/2021100.00Manual4
3001Dr Evil3/1/20213/1/20212/15/2021100.00Manual2
3001Dr Evil3/15/20213/1/20212/15/2021100.00Manual2

 

CASE

Case number Account numberCreated DateCase Type
1300011/20/2020Sales
230012/15/2021Billing
330022/5/2021Sales
430032/6/2021General
530042/7/2021Escalation
630052/20/2021Service
730012/28/2021General
830013/20/2021General
930013/31/2021General

 

 

 

 

1 ACCEPTED SOLUTION

I had some help and was able to figure it out.

Column = Calculate(Count(Case[Account Number]), Filter(Case Table,

Invoice [Account Number] = Case[Account Number] &&

Case[Created_Date] >= Invoice[Invoice Date] && Case[Created_Date] <= Invoice[Invoice Date] +90)

View solution in original post

5 REPLIES 5
Jorgast
Resolver II
Resolver II

Here is some sample data with the desired results and table relationships

Jorgast_0-1614782052787.png

 

Case_NumberAccount NumberCreated_DateType
1066662941057/2/2020 14:42General
1086855421058/4/2020 13:08General
11394185010510/30/2020 13:52General
11394190310510/30/2020 13:52General
11394190410510/30/2020 13:52General
11394190510510/30/2020 13:52General
11394193510510/30/2020 13:52General
11482585010511/16/2020 14:32General
11483414510511/16/2020 15:39General
11483604110511/16/2020 15:53General
11483604210511/16/2020 15:53General
11548103510511/27/2020 18:02General
12547890010512/5/2020 18:02Billing
13004931810512/17/2020 16:59General
1300928461051/13/2021 8:59Billing
1301214671051/25/2021 11:11Billing
10444280091212/1/2020 12:41General
10744123991212/14/2020 20:32General
10849815291212/31/2020 12:03General
1113488849121/17/2021 13:37General

 

 

 

 

 

Invoice #Account NumberInvoice DatePrev PaymentAmount DueDesired Result - Count of Cases within 90 days of Invoice Date
65793110511/20/2020 0:00-615.06-615.065
66009810512/21/2020 0:00-470.89144.172
219005691212/1/2020 0:00-2208.13-2208.134
21999719122/1/2021 0:00000

I had some help and was able to figure it out.

Column = Calculate(Count(Case[Account Number]), Filter(Case Table,

Invoice [Account Number] = Case[Account Number] &&

Case[Created_Date] >= Invoice[Invoice Date] && Case[Created_Date] <= Invoice[Invoice Date] +90)

amitchandak
Super User
Super User

@Jorgast , I case these tables are joins on [Account Number]  you can create a new measure

 

 

countx(summarize('Invoice Table' ,'Invoice Table' [Account Number] , "_1" , if(DateDiff(Min( 'Invoice Table' [Invoice Created Date]),Min('Case Table'[Created Date]), DAY) <= 90,1,blank())),[_1])

 

 

Or Create a new  column in invoice table

datediff('Invoice Table' [Invoice Created Date], minx( filter('Case Table','Case Table'[Account Number] = 'Invoice Table' [Account Number]),[Created Date]), DAY)

 

refer how to copy column values - https://www.youtube.com/watch?v=czNHt7UXIe8

In this case, i have the Invoice table and the case table joined to the date table, so I can have a 1:Many relationship

Hi @Jorgast ,

 

Can you provide some sample data with expected output for test?

 

Best Regards,
Kelly

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

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.