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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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