Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
sanjurk_1506
Regular Visitor

Patient Tracker and Package Tracker

Hi,

I have two  excel sheets one in which patient attendance is tracked with which therapist has been attended. Another sheet that says the type of package that the patients has bought. 

 

Every day I need to calculate the revenue by each Therapist. I have attached both the sheets, to show the type of data that is being generated from the system. There are few things to note here.

 

The cost per package for each therapist differs. 

For the same patient Speech Therapy Package will be different price and Occupational Therapy Price will be different price. 

The package price also differs for each patient on the day of purchase of the package from and to mentioned below

 

 

Patient Attendance Tracker 

Patient NamePatient IDTherapistDepartmentDate
Shyam Hani153RyaanOccupational Therapy02/10/2024
Shyam Hani153RyaanOccupational Therapy04/09/2024
Shyam Hani153RyaanOccupational Therapy06/09/2024
Shyam Hani153SanjuSpeech Therapy02/10/2024
Shyam Hani153SanjuSpeech Therapy04/09/2024
Shyam Hani153SanjuSpeech Therapy05/10/2024
Shyam Hani153SanjuSpeech Therapy06/09/2024
Shyam Hani153SanjuSpeech Therapy07/09/2024
Meera Hasan152SanjuSpeech Therapy09/10/2024
Meera Hasan152SanjuSpeech Therapy09/10/2024
Meera Hasan152SanjuSpeech Therapy10/08/2024
Meera Hasan152SanjuSpeech Therapy11/09/2024
Meera Hasan152SanjuSpeech Therapy11/09/2024
Meera Hasan152SanjuSpeech Therapy11/10/2024
Meera Hasan152SanjuSpeech Therapy11/10/2024
Meera Hasan152SanjuSpeech Therapy12/10/2024
Dev Mani112SanjuOccupational Therapy01/10/2024
Dev Mani112SanjuOccupational Therapy02/10/2024
Dev Mani112SanjuOccupational Therapy04/10/2024
Dev Mani112SanjuOccupational Therapy08/10/2024
Dev Mani112SanjuOccupational Therapy09/10/2024
Dev Mani112SanjuOccupational Therapy10/09/2024
Dev Mani112SanjuOccupational Therapy10/10/2024
Dev Mani112RyaanOccupational Therapy11/09/2024
Dev Mani112RyaanOccupational Therapy11/10/2024
Dev Mani112RyaanOccupational Therapy12/09/2024
Dev Mani112RyaanOccupational Therapy01/10/2024
Dev Mani112RyaanOccupational Therapy04/10/2024
Dev Mani112RyaanOccupational Therapy08/10/2024
Dev Mani112RyaanOccupational Therapy10/10/2024

 

 

Patient Price Tracker

 

Patient NameTherapistPatient IDPackage FromPackage ToPackage PricePackage
Shyam HaniSanju153Wednesday, 2 October 2024Wednesday, 4 September 2024100Speech Therapy
Shyam HaniRyaan153Wednesday, 2 October 2024 0Occupational Therapy
Meera HasanSanju152Wednesday, 9 October 2024Saturday, 12 October 2024200Occupational Therapy
Dev ManiSanju112Tuesday, 1 October 2024Tuesday, 8 October 2024300Occupational Therapy
Dev ManiRyaan112Saturday, 27 July 2024Tuesday, 27 August 2024400Occupational Therapy
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @sanjurk_1506 ,

 

Do you want to get package price for each recored in Patient Attendance Tracker? If so , you could add a caculate column for Patient Attendance Tracker. I'v made a test for your reference:

Package Price = CALCULATE(
    MAX('atient Price Tracker'[Package Price]),
    FILTER(
        'atient Price Tracker',
        'atient Price Tracker'[Patient ID] = 'Patient Attendance Tracker'[Patient ID] &&
        'atient Price Tracker'[Package] = 'Patient Attendance Tracker'[Department] &&
        'atient Price Tracker'[Package To] >= 'Patient Attendance Tracker'[Date] &&
        ('atient Price Tracker'[Package From] <= 'Patient Attendance Tracker'[Date] || IsBlank('atient Price Tracker'[Package From]))
    )
)

vbofengmsft_0-1730101569590.png

 

 

Best Regards,
Bof

 

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @sanjurk_1506 ,

 

Do you want to get package price for each recored in Patient Attendance Tracker? If so , you could add a caculate column for Patient Attendance Tracker. I'v made a test for your reference:

Package Price = CALCULATE(
    MAX('atient Price Tracker'[Package Price]),
    FILTER(
        'atient Price Tracker',
        'atient Price Tracker'[Patient ID] = 'Patient Attendance Tracker'[Patient ID] &&
        'atient Price Tracker'[Package] = 'Patient Attendance Tracker'[Department] &&
        'atient Price Tracker'[Package To] >= 'Patient Attendance Tracker'[Date] &&
        ('atient Price Tracker'[Package From] <= 'Patient Attendance Tracker'[Date] || IsBlank('atient Price Tracker'[Package From]))
    )
)

vbofengmsft_0-1730101569590.png

 

 

Best Regards,
Bof

 

@Anonymous 

 

This is working out, but is there a change that could be done that, instead of 0 I have put 200 on the second line below.

 

What I meant by the blank is that the package starts from Wednesday, 2 October 2024, but the end date is nto know, so until then the package price will 200.

 

The blanks mean that the end date of the package is not known - it will be either when the client stops coming.

 

atient NameTherapistPatient IDPackage FromPackage ToPackage PricePackage
Shyam HaniSanju153Wednesday, 2 October 2024Wednesday, 4 September 2024100Speech Therapy
Shyam HaniRyaan153Wednesday, 2 October 2024 200Occupational Therapy
dk_dk
Super User
Super User

Hi @sanjurk_1506 

 

 

You could do the following:

Transform the Patient Price Tracker as per this blog post: https://amitchandak.medium.com/power-query-get-all-dates-between-the-start-and-end-date-9ad6a84cf5f2

Creating new rows for the dates between the "package from" and "package to" columns, for each original row. You can call this new column Date.

 

 

In both tables, you need to create a custom ID column in format like this, or similar:

 

<patient_id>_<package/department>_<therapist>_<date>

 

so the first row in your first table, the value will be:

153_Occupational Therapy_Ryaan_02/10/24

 

and this should be the same but with Speech Therapy for the first row in your second table, after you add the custom column for the dates and expand it to rows

 

Then you can merge the two queries together based on this ID column, and expand only the Package price. (if the package price is price per day, you dont need to do anything. if the package price is price for all the days, then you need to divide the package price by the number of days that is the duration of the package (you can calculate this as a separate custom column in the second table based on the From and To dates).

 

I hope this helps, let me know if you run into any issues and I will try to clarify further.

 




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

Proud to be a Super User!





Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.