Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
Hi all,
We have a "Discount Table" looking somewhat like this:
SupplierID | LanguageID | ProductTypeID | WorkAreaID | DiscountSettings |
1 | 1 | 1 | 1 | 50% |
1 | 2 | 1 | 2 | 50% |
1 | 2 | 1 | 1 | 50% |
1 | 3 | 1 | 2 | 50% |
Then we have a "Sales table" looking somewhat like this:
JobID | Price | SupplierID | LanguageID | ProductTypeID | WorkAreaID |
100 | 100 | 1 | 1 | 1 | 1 |
101 | 100 | 1 | 2 | 1 | 2 |
102 | 100 | 1 | 3 | 1 | 2 |
103 | 100 | 1 | 3 | 1 | 2 |
104 | 100 | 1 | 2 | 1 | 1 |
105 | 100 | 1 | 1 | 1 | 1 |
106 | 100 | 1 | 2 | 1 | 1 |
107 | 100 | 1 | 2 | 1 | 1 |
108 | 100 | 1 | 3 | 1 | 2 |
109 | 100 | 1 | 2 | 1 | 2 |
110 | 100 | 1 | 2 | 1 | 2 |
I would like to get a "Job count" and "Price" for each "Setting" based on first table.
So I would like an output somewhat like this:
SupplierID | LanguageID | ProductTypeID | WorkAreaID | DiscountSettings | Number of Jobs | Price |
1 | 1 | 1 | 1 | 50% | 2 | 200 |
1 | 2 | 1 | 2 | 50% | 3 | 300 |
1 | 2 | 1 | 1 | 50% | 3 | 300 |
1 | 3 | 1 | 2 | 50% | 3 | 300 |
I am not sure how to combine the tables without a "unique key".
So an example for me would be to know the "Price" and "Job count" for each SupplierID=1, where LanguageID=1, ProductTypeID=1, WorkAreaID=1 and DiscountSettings=50%.
And then I would just need all possible combinations.
Please help! 🙂
Solved! Go to Solution.
@PeterStuhr concatenate columns to create a surrogate key to set the relationship between tables and then you can get data from the table pretty easily.
I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!
⚡Visit us at https://perytus.com, your one-stop shop for Power BI related projects/training/consultancy.⚡
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Hi @PeterStuhr ,
Try create measures like below:
Price =
CALCULATE (
SUM ( 'Table (2)'[Price] ),
FILTER (
'Table (2)',
'Table (2)'[SupplierID] = MAX ( 'Table'[SupplierID] )
&& 'Table (2)'[ProductTypeID] = MAX ( 'Table'[ProductTypeID] )
&& 'Table (2)'[WorkAreaID] = MAX ( 'Table'[WorkAreaID] )
&& 'Table (2)'[LanguageID] = MAX ( 'Table'[LanguageID] )
)
)
Job count=
CALCULATE (
COUNT( 'Table (2)'[JobId] ),
FILTER (
'Table (2)',
'Table (2)'[SupplierID] = MAX ( 'Table'[SupplierID] )
&& 'Table (2)'[ProductTypeID] = MAX ( 'Table'[ProductTypeID] )
&& 'Table (2)'[WorkAreaID] = MAX ( 'Table'[WorkAreaID] )
&& 'Table (2)'[LanguageID] = MAX ( 'Table'[LanguageID] )
)
)
Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @PeterStuhr ,
Try create measures like below:
Price =
CALCULATE (
SUM ( 'Table (2)'[Price] ),
FILTER (
'Table (2)',
'Table (2)'[SupplierID] = MAX ( 'Table'[SupplierID] )
&& 'Table (2)'[ProductTypeID] = MAX ( 'Table'[ProductTypeID] )
&& 'Table (2)'[WorkAreaID] = MAX ( 'Table'[WorkAreaID] )
&& 'Table (2)'[LanguageID] = MAX ( 'Table'[LanguageID] )
)
)
Job count=
CALCULATE (
COUNT( 'Table (2)'[JobId] ),
FILTER (
'Table (2)',
'Table (2)'[SupplierID] = MAX ( 'Table'[SupplierID] )
&& 'Table (2)'[ProductTypeID] = MAX ( 'Table'[ProductTypeID] )
&& 'Table (2)'[WorkAreaID] = MAX ( 'Table'[WorkAreaID] )
&& 'Table (2)'[LanguageID] = MAX ( 'Table'[LanguageID] )
)
)
Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@PeterStuhr concatenate columns to create a surrogate key to set the relationship between tables and then you can get data from the table pretty easily.
I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!
⚡Visit us at https://perytus.com, your one-stop shop for Power BI related projects/training/consultancy.⚡
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
User | Count |
---|---|
139 | |
113 | |
103 | |
73 | |
63 |
User | Count |
---|---|
136 | |
125 | |
107 | |
70 | |
61 |