Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hello everyone,
I'm really frustrated and I hope you can help me.
I have two tables that only match the article number. Both tables have a date. If the date from the log table is greater than or equal to the date from the item table, the price should appear in the column and apply from then until a new price is set.
You have an idea for a measure ?
Example:
Initial situation
Item table:
Item | Date | |
A | 01/30/2020 | |
A | 01/31/2020 | |
A |
| 02/02/2020 |
A |
| 02/23/2020 |
A |
| 02/25/2020 |
Log table:
Item | Log date | Sell price | Buy price | |||
A | 01/30/2020 | $5,00 | $2,00 | |||
A | 02/03/2020 | $4,00 | $3,00 |
Expected sitation:
Item table:
Item | Date | Sell price | Buy price | |||
A | 01/30/2020 | $5,00 | $2,00 | |||
A | 01/31/2020 | $5,00 | $2,00 | |||
A | 02/02/2020 | $5,00 | $2,00 | |||
A | 02/23/2020 | $4,00 | $3,00 | |||
A | 02/25/2020 | $4,00 | $3,00 |
Solved! Go to Solution.
Hi, @azaterol ;
Try this measure:
Sell price =
var _maxdate=CALCULATE(MAX('Log'[Log date]),FILTER('Log',[Log date]<=MAX('Item'[Date])))
return CALCULATE(MAX('Log'[Sell price]),FILTER('Log',[Log date]=_maxdate))
Buy price =
var _maxdate=CALCULATE(MAX('Log'[Log date]),FILTER('Log',[Log date]<=MAX('Item'[Date])))
return CALCULATE(MAX('Log'[Buy price]),FILTER('Log',[Log date]=_maxdate))
The final show:
Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, @azaterol ;
Try this measure:
Sell price =
var _maxdate=CALCULATE(MAX('Log'[Log date]),FILTER('Log',[Log date]<=MAX('Item'[Date])))
return CALCULATE(MAX('Log'[Sell price]),FILTER('Log',[Log date]=_maxdate))
Buy price =
var _maxdate=CALCULATE(MAX('Log'[Log date]),FILTER('Log',[Log date]<=MAX('Item'[Date])))
return CALCULATE(MAX('Log'[Buy price]),FILTER('Log',[Log date]=_maxdate))
The final show:
Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @ Azaterol,
Please find the code for your 2 requested columns
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
111 | |
94 | |
83 | |
66 | |
59 |
User | Count |
---|---|
151 | |
121 | |
104 | |
87 | |
67 |