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
Anonymous
Not applicable

Average by Field bases on other field value

Good morning,

 

I'm quite new on DAX so I was wondering if someone can help me solving this issue…

 

Business: maritime public passenger transportation.

 

The DB is organized by Booking code that has a sailingcode associated. Every line of this DB is a passenger (a Booking can handle more than one passenger). The diferrent bookings for the same sailing have the same Sailing Code. Another field of this DB is the Ship name associated to the sailing of the booking.

 

What I'm trying to know is the average number of passanger transported by each ship, in the total of sailings performed in a certain period.

 

To calculate the total number of passangers in a certain period or from origin x to destination y, we have a measure that count all de bookings that are "CONFIRMED" in the status field.

 

I've already tried to create a measure with this expression

 

Ocupação Média por Navio(UnderConst) = AVERAGEX(VALUES(vw_Report_REPLICA_Invoices_Details[VesselName]);SUM(vw_Report_REPLICA_Invoices_Details[NumPassageiros]))

 

But it didn't worked…

 

Do you have any ideia what I might be doing wrong?

 

Thank you,

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

Hi @Anonymous ,

 

Try the following DAX:

Ocupação Média por Navio(UnderConst) =
AVERAGEX (
    ALLEXCEPT (
        vw_Report_REPLICA_Invoices_Details;
        vw_Report_REPLICA_Invoices_Details[VesselName]
    );
    SUM ( vw_Report_REPLICA_Invoices_Details[NumPassageiros] )
)

If it doesn't work, you could share your sample data and excepted result to me if you don't have any Confidential Information. Please upload your files to OneDrive for Business and share the link here.

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.

View solution in original post

4 REPLIES 4
v-eachen-msft
Community Support
Community Support

Hi @Anonymous ,

 

Has your problem been solved? Was my reply helpful to you? If the problem is resolved, you could accept the reply you like.

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.
v-eachen-msft
Community Support
Community Support

Hi @Anonymous ,

 

Try the following DAX:

Ocupação Média por Navio(UnderConst) =
AVERAGEX (
    ALLEXCEPT (
        vw_Report_REPLICA_Invoices_Details;
        vw_Report_REPLICA_Invoices_Details[VesselName]
    );
    SUM ( vw_Report_REPLICA_Invoices_Details[NumPassageiros] )
)

If it doesn't work, you could share your sample data and excepted result to me if you don't have any Confidential Information. Please upload your files to OneDrive for Business and share the link here.

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.
amitchandak
Super User
Super User

@Anonymous, Try Like

Ocupação Média por Navio(UnderConst) = AVERAGEX(summarize(vw_Report_REPLICA_Invoices_Details;
vw_Report_REPLICA_Invoices_Details[VesselName];"_sum";SUM(vw_Report_REPLICA_Invoices_Details[NumPassageiros]));[_sum])

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Hi amitchandak, thank for your help. Unfortunatly this expression output is the same of the one I had before...

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!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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.