Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi everyone,
Happy holidays!
I need to show the evolution of the cost of products and I have the following datasets:
Product | Ingredient | % of ingredient in the product | Month&Year of formula update |
A | A1 | 0.5 | 03/2021 |
A | A2 | 0.5 | 03/2021 |
A | A1 | 0.6 | 06/2022 |
A | A3 | 0.4 | 06/2022 |
Ingredients | Month&Year of cost | Cost |
A1 | 01/2021 | u |
A1 | 02/2021 | v |
A1 | 03/2021 | x |
... | ... | ... |
I need to create a table which shows me:
By taking the correct Ingredient, % of ingredient in the product and Cost, depending on the relationship between Month&Year of formula update and the Month&Year of cost. Example:
Product | Ingredient | % of ingredient in the product * Cost | Month&Year of cost |
A | A1 | 0.5 * x | All "Year&Month of cost" after 03/2021 and before 06/2022 |
A | A2 | 0.5 * y | All "Year&Month of cost" after 03/2021 and before 06/2022 |
A | A1 | 0.6 * w | All "Year&Month of cost" after 06/2022 |
A | A3 | 0.4 * z | All "Year&Month of cost" after 06/2022 |
I was thinking about merging table Number 1 with table Number 2, but I don't know how to tell PowerBI to implement the right logic for which products formulas to use depending on the dates...
Any thoughts?
Thanks!
Solved! Go to Solution.
Hi @Anonymous ,
Please try below steps:
1. below is my test table
Table1:
Table2:
2. create a measure with below dax formula
Measure =
VAR cur_ingre =
SELECTEDVALUE ( Table1[% of ingredient in the product] )
VAR cur_it =
SELECTEDVALUE ( Table1[Ingredient] )
VAR cur_ym =
SELECTEDVALUE ( Table1[Month&Year of formula update] )
VAR tmp =
FILTER (
ALL ( 'Table 2' ),
'Table 2'[Ingredients] = cur_it
&& 'Table 2'[Month&Year of cost] >= cur_ym
)
VAR _date =
MINX ( tmp, [Month&Year of cost] )
VAR _val =
CALCULATE (
MAX ( 'Table 2'[Cost] ),
'Table 2'[Ingredients] = cur_it,
'Table 2'[Month&Year of cost] = _date
)
RETURN
cur_ingre & " * " & _val
3. add a table visual with Table1 fields and measure
Please refer the attached .pbix file.
Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous ,
Please try below steps:
1. below is my test table
Table1:
Table2:
2. create a measure with below dax formula
Measure =
VAR cur_ingre =
SELECTEDVALUE ( Table1[% of ingredient in the product] )
VAR cur_it =
SELECTEDVALUE ( Table1[Ingredient] )
VAR cur_ym =
SELECTEDVALUE ( Table1[Month&Year of formula update] )
VAR tmp =
FILTER (
ALL ( 'Table 2' ),
'Table 2'[Ingredients] = cur_it
&& 'Table 2'[Month&Year of cost] >= cur_ym
)
VAR _date =
MINX ( tmp, [Month&Year of cost] )
VAR _val =
CALCULATE (
MAX ( 'Table 2'[Cost] ),
'Table 2'[Ingredients] = cur_it,
'Table 2'[Month&Year of cost] = _date
)
RETURN
cur_ingre & " * " & _val
3. add a table visual with Table1 fields and measure
Please refer the attached .pbix file.
Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@Anonymous , You can check to merge in power query, and you can select multiple column to join
Merge Tables (Power Query) : https://www.youtube.com/watch?v=zNrmbagO0Oo&list=PLPaNVDMhUXGaaqV92SBD5X2hk3TMNlHhb&index=16
or copy columns in DAX
refer 4 ways (related, relatedtable, lookupvalue, sumx/minx/maxx with filter) to copy data from one table to another
https://www.youtube.com/watch?v=Wu1mWxR23jU
https://www.youtube.com/watch?v=czNHt7UXIe8
or DAX joins
https://www.sqlbi.com/articles/from-sql-to-dax-joining-tables/
Thanks @amitchandak. My difficulty is on knowing which expression to use to get the right ingredients and % of ingredient in the product depending on the dates...
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
72 | |
70 | |
37 | |
29 | |
26 |
User | Count |
---|---|
91 | |
49 | |
45 | |
38 | |
37 |