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
ryan_b_fiting
Post Patron
Post Patron

Calculate Billings by Provider based on number of months after start date

Hello Community - 

 

I am in need of some help on calculating Sales for Providers, but I am looking to baseline it on the providers 1st month, 2nd month and so on.  I have a provider data table in my model that has the provider details and their start date (ehr_providers), then a billings table that has the amount billed by date (ehr_billings).

 

What I am looking to do is calculate is each providers billings in their 1st,2nd, 3rd.......12th month to be able to compare the providers.  So this would be a sample of the output I would expect:

 

Provider IDStart MonthMonth 1Month 2Month 3
11/1/2023 10,000.00 15,000.00 20,000.00
25/1/2023 12,000.00 19,000.00 21,000.00
311/1/2023  7,600.00 22,000.00 

 

Provider 1 - Month 1 of $10k would be for January 2023, Month 2 of $15k for Feb 2023, Month 3 of $20k for March 2023

Provider 2 - Month 1 of $12k for May 2023 Month 2 of $19k for June 2023 and Month 3 of $21k for July 2023

Provider 3 - Month 1 of $7.6k for Nov 2023, Month 2 of $22k for Dec 2023 and there is nothing for Month 3 because we have the data currently stopped at December 31, 2023.

 

We want to compare how our providers are doing when they start and how they are growing in the roles and be able to baseline that on their number of months they have been practicing with us.

 

As always any help is greatly appreciated here.

Thanks

Ryan F.

1 ACCEPTED SOLUTION
v-zhengdxu-msft
Community Support
Community Support

Hi @ryan_b_fiting 

 

Sorry, I'm not sure why only True and False are output on your side,  I'll tell you more about what I'm doing:

First, I created a table based on the data you provided:

vzhengdxumsft_0-1705477770724.png

Then create a table to store the dates for subsequent months:

 

Table = {"1Month","2Month","3Month"}

 

Then I made a modification to the previous measure:

 

()month = 
    VAR mon_value = SELECTEDVALUE('Table'[Value])
    VAR Newmonth = SWITCH(
        mon_value,
        "1Month", 0,
        "2Month", 1,
        "3Month", 2
    )
//Match the date to be added to the value in the table
    VAR required_Date = DATE(YEAR(MIN('Billing'[Visit Date])),MONTH(MIN('Billing'[Visit Date]))+Newmonth,DAY(MIN('Billing'[Visit Date])))
//Returns the current date
    RETURN
        CALCULATE(
            SUM('Billing'[ Billing $ ]),
            MONTH('Billing'[Visit Date]) = MONTH(
                required_Date
                )
            &&
            YEAR('Billing'[Visit Date]) = YEAR(
                required_Date
                )
        )
//The values of all billings for each month are summed and output in order of month
//Filter by year and month

 

Then create a matrix:

vzhengdxumsft_1-1705477866314.pngvzhengdxumsft_2-1705477866316.png

The result is as follow:

vzhengdxumsft_3-1705477872945.png

 

Best Regards,

Zhengdong Xu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

6 REPLIES 6
v-zhengdxu-msft
Community Support
Community Support

Hi @ryan_b_fiting 

 

Sorry, I'm not sure why only True and False are output on your side,  I'll tell you more about what I'm doing:

First, I created a table based on the data you provided:

vzhengdxumsft_0-1705477770724.png

Then create a table to store the dates for subsequent months:

 

Table = {"1Month","2Month","3Month"}

 

Then I made a modification to the previous measure:

 

()month = 
    VAR mon_value = SELECTEDVALUE('Table'[Value])
    VAR Newmonth = SWITCH(
        mon_value,
        "1Month", 0,
        "2Month", 1,
        "3Month", 2
    )
//Match the date to be added to the value in the table
    VAR required_Date = DATE(YEAR(MIN('Billing'[Visit Date])),MONTH(MIN('Billing'[Visit Date]))+Newmonth,DAY(MIN('Billing'[Visit Date])))
//Returns the current date
    RETURN
        CALCULATE(
            SUM('Billing'[ Billing $ ]),
            MONTH('Billing'[Visit Date]) = MONTH(
                required_Date
                )
            &&
            YEAR('Billing'[Visit Date]) = YEAR(
                required_Date
                )
        )
//The values of all billings for each month are summed and output in order of month
//Filter by year and month

 

Then create a matrix:

vzhengdxumsft_1-1705477866314.pngvzhengdxumsft_2-1705477866316.png

The result is as follow:

vzhengdxumsft_3-1705477872945.png

 

Best Regards,

Zhengdong Xu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

v-zhengdxu-msft
Community Support
Community Support

Hi @ryan_b_fiting 

 

I already understand your needs:

You want to compare how well our providers are doing at the beginning and how they've grown in the role, showing data for the subsequent months of the start date;

Here is my solution:

First, I created a new table to store the dates for subsequent months:

vzhengdxumsft_2-1704875678214.png

Then create a measure:

 

()month =
    VAR mon_value = SELECTEDVALUE('Table'[Value])
    VAR Newmonth = SWITCH(
        mon_value,
        "1Month", 0,
        "2Month", 1,
        "3Month", 2
    )
//Match the date to be added to the value in the table
    VAR current_month = MIN('Billing'[Month])
//Returns the current date
    RETURN
        CALCULATE(
            SUM('Billing'[ Billing $ ]),
            'Billing'[Month] = current_month + Newmonth
        )
//The values of all billings for each month are summed and output in order of month

 

The result is as followed:

vzhengdxumsft_3-1704875678218.png

 

Best Regards,

Zhengdong Xu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Thanks for the reply @v-zhengdxu-msft unfortunately when I try to replicate this and tweak it for my data, it only provides me with TRUE or FALSE output.  It does not offset the months.  Unforutnately I cannot just use a month number because these will cross over years, so If they start in November, I cannot just add 3 to the current month.

 

I am trying to figure out another solution for this so any additional tips would be great.

Ashish_Mathur
Super User
Super User

Hi,

Share input data in a format that can be pasted in an MS Excel file and show the expected resutl on that dataset.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Here are some sample sets of the data:

The explanation of what we are trying to complete is in the original post:

 

Expected Output:

Provider IDStart MonthMonth 1Month 2Month 3
11/1/2023 10,000.00 15,000.00 20,000.00
25/1/2023 12,000.00 19,000.00 21,000.00
311/1/2023    7,600.00 22,000.00 

Provider Table Sample:

Provider IDProvider NameStart Date
1A1/1/2023
2B5/1/2023
3C

11/1/2023

 

Billing Table Sample:

Billing IDProvider IDVisit Date Billing $ 
111/7/2023 $   2,000.00
211/20/2023 $   3,000.00
311/30/2023 $   5,000.00
412/15/2023 $   5,000.00
512/20/2023 $10,000.00
613/3/2023 $   2,000.00
713/10/2023 $   6,000.00
813/15/2023 $12,000.00
925/10/2023 $   4,500.00
1025/20/2023 $   7,500.00
1126/4/2023 $   3,000.00
1226/9/2023 $   3,000.00
1326/21/2023 $   7,000.00
1426/30/2023 $   6,000.00
1527/2/2023 $   9,000.00
1627/15/2023 $   4,000.00
1727/20/2023 $   8,000.00
18311/15/2023 $   2,100.00
19311/23/2023 $   5,500.00
20312/12/2023 $   8,000.00
21312/15/2023 $   4,500.00
22312/23/2023 $   6,500.00
23312/30/2023 $   3,000.00

A similar problem has been solved in the attached file.

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

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.