Forum Discussion
Search Part Cost
- 4 years ago
If the field types of the two tables are synchronized, it does not matter whether text or number.
Try this:
Column = VAR a = MAXX ( FILTER ( PART_COST_RATE, [PART_CODE] = EARLIER ( 'Table'[PART_CODE] ) && [EFECT_FROM_DATE] <= EARLIER ( 'Table'[MANUFACTURE DATE] ) ), [EFECT_FROM_DATE] ) RETURN MAXX ( FILTER ( PART_COST_RATE, [EFECT_FROM_DATE] = a && [PART_CODE] = EARLIER ( 'Table'[PART_CODE] ) ), [RATE] )Are you sure there are matching results in the two tables?
Best Regards,Community Support Team _ Janey
Hi Yonatan1984
Can you post sample data as text and expected output?
Not enough information to go on;
please see this post regarding How to Get Your Question Answered Quickly:
https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490
The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.
4. Relation between your tables
Appreciate your Kudos!!
LinkedIn:www.linkedin.com/in/vahid-dm/
Hi VahidDM
for Exmple, this is The DB for PART_COST_RATE:
| RATE | EFECT_FROM_DATE | PART_CODE |
| 20 | 01/01/2019 | 111 |
| 25 | 01/01/2019 | 222 |
| 30 | 21/03/2020 | 111 |
| 45 | 01/01/2019 | 333 |
| 50 | 01/01/2019 | 444 |
| 26 | 30/05/2020 | 111 |
| 39 | 05/07/2021 | 444 |
| 10 | 12/09/2020 | 333 |
| 5 | 01/01/2019 | 555 |
| 15 | 03/08/2021 | 111 |
| 57 | 05/09/2021 | 333 |
| 16 | 21/03/2020 | 222 |
This is the output that I need to show:
| PART_CODE | MANUFACTURE DATE | QNTY MANUFACTRED | RATE | COST |
| 111 | 30/01/2019 | 1253 | 20 | 25,060 |
| 222 | 02/04/2019 | 1405 | 25 | 35,125 |
| 111 | 30/04/2020 | 1286 | 30 | 38,580 |
| 333 | 05/07/2020 | 836 | 45 | 37,620 |
| 444 | 20/12/2019 | 745 | 50 | 37,250 |
| 111 | 19/08/2019 | 941 | 20 | 18,820 |
| 444 | 10/01/2020 | 1086 | 50 | 54,300 |
| 333 | 24/04/2021 | 983 | 10 | 9,830 |
| 555 | 10/12/2020 | 1126 | 5 | 5,630 |
| 111 | 23/05/2021 | 1305 | 26 | 33,930 |
| 333 | 29/10/2019 | 890 | 45 | 40,050 |
| 222 | 23/05/2020 | 1332 | 16 | 21,312 |
- VahidDM4 years ago
Super User
I think you missed to share all data tabels! Can you please explain how did you calculate QNTY or MANUFACTURE DATE?
Appreciate your Kudos!!
LinkedIn: www.linkedin.com/in/vahid-dm/- Yonatan19844 years ago
Helper I
Hi VahidDM
I did not miss nothing.
The manufacture date and the qnty base on the user input in power apps application that I build.
The rate price is the manufacture cost according to the product tree.
The rate change according to the material cost that we get from the supplier.
For exmple:
Before the covid-19, the prices was stable of the materials.
After the covid-19 started the prices are up.
The manufacture date isn't dependent of the change rate, the factory must to manufactre the items.
- VahidDM4 years ago
Super User
Hi Yonatan1984
Use this code to add a RATE column to the output table:
Rate Calculated Column = VAR _A = [PART_CODE] VAR _B = [MANUFACTURE DATE] VAR _C = CALCULATE ( MAX ( PART_COST_RATE[EFECT_FROM_DATE] ), FILTER ( ALL ( PART_COST_RATE ), PART_COST_RATE[PART_CODE] = _A && PART_COST_RATE[EFECT_FROM_DATE] <= _B ) ) RETURN CALCULATE ( MAX ( PART_COST_RATE[RATE] ), FILTER ( ALL ( PART_COST_RATE ), PART_COST_RATE[PART_CODE] = _A && PART_COST_RATE[EFECT_FROM_DATE] = _C ) )Output:
then multiply the New Rate column by QTY to find the COST.
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: www.linkedin.com/in/vahid-dm/