Forum Discussion
Creating a dynamic matrix with same row and column names and calculated field values
Hi,
I've got a table with item information. Each item has one row.
I want to create a matrix where the rows are still the items, and the columns are the items as well. The columns need to be dynamically added so when the data is updated and new items were added, new columns for the created items are added as well.
The next step would be to add a calculation for each column and row, which counts sales orders of an other table where the item "a" of the row and the item "b" of each column are sold together.
It should look like this:
ItemNo Chair Table Lamp
| Chair | x | 2 | 5 |
| Table | 2 | x | 6 |
| Lamp | 5 | 6 | x |
Does anyone have an idea how to do that?
To do this, you are likely going to need to make a second table that has your items column. You will use the one from first table in rows or columns and the new one in the other. This approach is explained on SQLBI as "Basket Analysis". Please see this pattern explained there. Note this is an older article from a time when the relationship filter arrows went the opposite direction.
https://www.daxpatterns.com/basket-analysis/
If this works for you, please mark it as solution. Kudos are appreciated too. Please let me know if not.
Regards,
Pat
3 Replies
- mahoneypat
Microsoft Employee
To do this, you are likely going to need to make a second table that has your items column. You will use the one from first table in rows or columns and the new one in the other. This approach is explained on SQLBI as "Basket Analysis". Please see this pattern explained there. Note this is an older article from a time when the relationship filter arrows went the opposite direction.
https://www.daxpatterns.com/basket-analysis/
If this works for you, please mark it as solution. Kudos are appreciated too. Please let me know if not.
Regards,
Pat
- parry2k
Super User
nex how your raw data looks like? You provided how you want the output to be but not what the raw data looks like? Sometimes the solutions can be totally different based on how raw data is available? Maybe there is a need of transformation before even data get used for the reporting purpose.
Read this post to get your answer quickly.
https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490 - nexRegular Visitor
Hi mahoneypat thanks for the reply. That is exactly what I was looking for.
Seems like i was making it more complicated than it actually is.
Thanks for the help!
parry2k Thank you for the advise. I will keep it in mind the next time.