Forum Discussion
Data modelling
Hi
i have two separate spreadsheets that I've loaded into power bi. Some of the columns have the same info ie month, department and product code. The other columns contain a value for a financial figure type. I'm trying to create a matrix that brings in figures from both spreadsheets. I've linked the tables by product in the modelling tab however matrix is still only recognising the figures from one of the spreadsheets and showing the others as 0. Thanks
13 Replies
- Analyst26New Member
Hi Sundar
I can't share company info unfortunately but really appreciate your response.
- Nasif_AzamSuper User
Hey Analyst26 ,
It sounds like you're on the right track by linking the tables via Product Code. However, the issue might be due to how the relationships are set up or how you're using the fields in your matrix. A few things to check:
Relationship Direction & Cardinality: Ensure the relationship between your tables is active and set correctly (typically one-to-many with the dimension table on the "one" side).
Common Dimension Table: Instead of linking the two fact tables directly, consider creating a separate dimension table (e.g., a Date or Product table) and relate both spreadsheets to that. This enables proper filtering across both.
Matrix Setup: If you're using columns from one table only in the matrix (like values from one table and not the other), the blank values may appear. Try using fields from the shared dimension tables (like Product or Date) for rows/columns in the matrix.
Measure Creation: Create separate measures for the financial figures from each table using DAX (e.g., SUM(Table1[Value]), SUM(Table2[Value])) and then bring those into the matrix.
For Detailed Information:
Create and manage relationships in Power BI
Model relationships in Power BI Desktop
Best practices for designing Power BI data models
Create a matrix visual in Power BI
DAX basics in Power BI Desktop
If you found this solution helpful, please consider accepting it and giving it a kudos (Like) it’s greatly appreciated and helps others find the solution more easily.
Best Regards,
Nasif Azam- Analyst26New Member
Hi Nasif
Thanks so much for your input. I have created a dimension table with company name, department and product code. Each of this 3 has a unique code so I've also done a merged column of these 3 codes. Some of the data in the merged column does duplicate. Due to this I've linked the two other spreadsheets to the merged column and created a many to many relationship - it's recognising the values of one set of figures from one excel dataset but still not the other!
- Nasif_AzamSuper User
Hey Analyst26 ,
You are very welcome. Thanks for the update, sounds like you are almost there! 😊
The issue now likely stems from the many-to-many relationship using the merged column. Many-to-many relationships can behave unpredictably in filtering, especially when used across multiple fact tables. My Recommendations:
1. Create Separate Dimension Tables: Instead of using a merged column for a combined key (Company + Department + Product Code), try splitting it out into separate dimension tables for:
Product (unique Product Code)
Department (unique Department Code)
Company (unique Company Code)
Then, relate both spreadsheets (fact tables) to these separate dimensions using one-to-many relationships. This structure is much more stable and improves filtering behavior in visuals like the matrix.
2. Use Measures Instead of Raw Columns: If you haven’t already, create measures for your values in each table, such as:
TotalValue_Table1 = SUM(Table1[FinancialValue]) TotalValue_Table2 = SUM(Table2[FinancialValue])
Use these measures in your matrix instead of dragging raw columns.
3. Avoid Using the Merged Column as a Link: Power BI doesn’t always filter many-to-many relationships well, especially with non-unique merged keys. A star schema (with separate dimension tables) is more reliable.
4. Check for Missing Matches: In one of the spreadsheets, the merged key values might not exactly match the other table or the dimension. Even extra spaces or different text casing can break joins. Use TRIM, CLEAN, or Power Query transformations to clean the values before loading.
If you found this solution helpful, please consider accepting it and giving it a kudos (Like) it’s greatly appreciated and helps others find the solution more easily.
Best Regards,
Nasif Azam
- danextianSuper User
Hi Analyst26
You will need to create separate dimension tables for the common dimensions between the two and use measures to combine the values from both. These can be created either in DAX or M or loaded from the data source. Example DAX calc table:
Products = VAR _tableA = SELECTCOLUMNS ( TableA, "Product ID", TableA[Product ID], "Product Name", TableA[Product Name] ) VAR _tableB = SELECTCOLUMNS ( TableB, "Product ID", TableB[Product ID], "Product Name", TableB[Product Name] ) RETURN DISTINCT ( UNION ( _tableA, _tableB ) )Create a one to-many single direction relationship from Product ID in this table to Product ID/code columns of the other tables. Use this column in your visual - not from your fact table. Create a measure to combine the aggregation from both fact tables. Example:
Sales Table A and B = SUM ( TableA[Sales] ) + SUM ( TableB[Sales] ) - AnonymousNot applicable
Hi Analyst26,
It looks like the issue is due to a relationship problem in the data model. Although you’ve connected the two spreadsheets by Product Code, fields like Month and Department used in the matrix may not be properly related across both tables. Because of this, Power BI is unable to filter both datasets correctly, resulting in 0s for one of them.
If this post helps, then please consider Accepting as solution to help the other members find it more quickly, don't forget to give a "Kudos" – I’d truly appreciate it!
Regards,
Vinay Pabbu - AnonymousNot applicable
Hi Analyst26,
I just wanted to follow up on your thread. If the issue is resolved, it would be great if you could mark the solution so other community members facing similar issues can benefit too.
If not, don’t hesitate to reach out, we’re happy to keep working with you on this.Regards,
Vinay Pabbu
- v-nmadadi-msftCommunity Support
Hi Analyst26 ,
I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions.
Thank you. - v-nmadadi-msftCommunity Support
Hi Analyst26 ,
As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided by the community members for the issue worked.
Thanks and regards