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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
rain-tm
Frequent Visitor

Calculating top product per row in a Table Chart where fields come from different table sources

Hi all,

 

I'm trying to product a table chart like this where I show each station, the total sales for the station and the top selling product and top vehicle customer for that station. However my current code shows a table where the sales is calculated correctly but the top product and top vehicle is wrong. Im guessing it's not calculating the top product and vehicle per row but across all stations since it's showing the same values for each row.

raintm_0-1676536691047.png

 

The fields used in the table come from different table sources since I'm following the star schema. Transactions is the fact table while the rest are dimension tables

raintm_1-1676536837837.png

For example, i'd get the Station Name from the Stations table while Total Sales form the Transactions table.

 

My current code for identifying the Top Product is

 

 

TopProduct = FIRSTNONBLANK(
    TOPN(
        1, VALUES(
            'Vehicles'[VehicleName]
        )
    ),
        SUM('Transactions'[SalesAmount])
)

 

 

 

Would really appreciate help on how to get the correct Top Vehicle and Product. Thank you!

2 REPLIES 2
rain-tm
Frequent Visitor

Thank you for this, but it unfortunately doesn't solve my issue 

Padycosmos
Solution Sage
Solution Sage

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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