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.
Hi all!
I have 2 tables:
1) SALES TABLE
Customer ID | Product ID | Date | Amount € |
1 | 55 | 03/01/2020 | 500 € |
2 | 66 | 01/02/2020 | 600 € |
3 | 55 | 01/02/2020 | 700 € |
2) COST TABLE
Product ID | Since Date | To Date | Cost € |
55 | 01/01/2020 | 31/01/2020 | 25 € |
55 | 01/02/2020 | 29/02/2020 | 30 € |
66 | 01/01/2020 | 31/07/2020 | 99 € |
Then, I want to obtain COST € for every row of first table.
I am not using date tables.My date filter is "DATE" of table "SALES TABLE". Thanks in advance.
Thanks in advance.
Solved! Go to Solution.
@jrscaletta , new column in sales table
new column: maxx(filter(cost, cost[Product ID] ?sales[Product ID] && Sales[Date]>'cost[From Date] && Sales[Date]<'cost[Date to]),Cost[Cost'])
Hi @jrscaletta,
Create a column as below:
Column =
var _cost=CALCULATE(MIN('COST TABLE'[ Cost €]),FILTER(ALL('COST TABLE'),'COST TABLE'[Product ID]='SALES TABLE'[Product ID]&&'COST TABLE'[Since Date]<=EARLIER('SALES TABLE'[Date])&&'COST TABLE'[ To Date]>=EARLIER('SALES TABLE'[Date])))
Return
_cost
And you will see:
For the related .pbix file,pls see attached.
Hi @jrscaletta,
Create a column as below:
Column =
var _cost=CALCULATE(MIN('COST TABLE'[ Cost €]),FILTER(ALL('COST TABLE'),'COST TABLE'[Product ID]='SALES TABLE'[Product ID]&&'COST TABLE'[Since Date]<=EARLIER('SALES TABLE'[Date])&&'COST TABLE'[ To Date]>=EARLIER('SALES TABLE'[Date])))
Return
_cost
And you will see:
For the related .pbix file,pls see attached.
@jrscaletta , new column in sales table
new column: maxx(filter(cost, cost[Product ID] ?sales[Product ID] && Sales[Date]>'cost[From Date] && Sales[Date]<'cost[Date to]),Cost[Cost'])
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 |
---|---|
110 | |
94 | |
80 | |
66 | |
58 |
User | Count |
---|---|
150 | |
119 | |
104 | |
87 | |
67 |