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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
zdenek_moravec
Advocate I
Advocate I

Advanced DAX required: What is the maximum occupancy of the bus during the journey?

Dear colleagues,

Imagine, You are a bus company manager and You would like to know, how is Your bus line occupied.

You have a list of all bus tickets in a table. Every record (ticket) consists of ticketID, from_station, to_station and number of passengers.

The question is "What is the maximum occupancy of the bus during the bus journey at any point in time?"

See max bus occupancy.pbix with a simplified fact table (without date) and a dim table with bus stops order. The picture in the report views describes my manual calculation, but I am not able to transform it into a DAX solution.

ChatGPT says "To determine the maxi.mum occupancy of the bus at any point in time, we need to track how many passengers are on board at each stop - calculate occupancy at each stop by summing boardings and subtracting alightings." But the DAX does not work even after many corrections.

Thank You very much for any hint.

Zdenek Moravec

Cesky Krumlov, Czechia

1 ACCEPTED SOLUTION
zdenek_moravec
Advocate I
Advocate I

Dear colleagues,

Thank You very much for Your responses. I will go through all solutions and try to apply to my full scenario of 1 mil tickets with many bus lines and dates. I will let You know, which solution is most suitable for me.

Zdenek

View solution in original post

8 REPLIES 8
zdenek_moravec
Advocate I
Advocate I

Dear colleagues,

Thank You very much for Your responses. I will go through all solutions and try to apply to my full scenario of 1 mil tickets with many bus lines and dates. I will let You know, which solution is most suitable for me.

Zdenek

Hi @zdenek_moravec,

May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.

Thank you.

Hi @zdenek_moravec,

May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.

Thank you.

v-saisrao-msft
Community Support
Community Support

Hi @zdenek_moravec,

May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.

Thank you.

v-saisrao-msft
Community Support
Community Support

Hi @zdenek_moravec,
I wanted to check if you had the opportunity to review the information provided by @ThxAlot @Ashish_Mathur @lbendlin . Please feel free to contact us if you have any further questions. If the response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
Thank you.

ThxAlot
Super User
Super User

Your question is just a variant of common "headcount" question, e.g. count active employees at certain point of periods. In such scenarios, it's not necessary to directly liaison date table (usually dim table) with fact table.

ThxAlot_0-1745056429466.png

ThxAlot_1-1745056483184.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LearnAndPractise(Everyday)


)



Ashish_Mathur
Super User
Super User

Hi,

PBI file attached.

Hope this helps.

Ashish_Mathur_0-1745034374770.png

 


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

Not sure if advanced DAX is required - the source data could be structured better.

 

lbendlin_0-1745023539053.png

 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors