Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
herbemischung
Resolver I
Resolver I

Merge tables based on time function?

Short introduction:

 

I've got a table with all bought products and their price:

 

Article ID | Date (received on) | Costs | ID_Entry

 

--> everytime we buy an article it gets an ID_Entry. 

00001 | 1.1.2019 | 0,50 | ENTR_01

00002 | 1.1.2019 | 2,48 | ENTR_02

.......

00001 | 5.3.2019 | 0,60 | ENTR_2315

 

We also have the possibility to correct the article status. This also generates an ID_Entry (in a different table) but without costs. 

 

Table B

00001 | 6.6.2019 | ENTR_3571 

 

Each sale refers to the ID_Entry. 

If we sell article 00001 (Fifo) with the Entry_ID ENTR_01 the costs are 0,5 / with ENTR_2315 0,6 

but there are no costs with Entr_3571.

 

I would need to get the costs of the latest article access below the entry date of the correction.

 

last access for article 00001 below 6.6.2019 -->5.3.2019 -->0,60

 

not sure if this can be done. thanks for help!

 

 

 

 

1 ACCEPTED SOLUTION

Yes, @Mariusz helped me with a formula. I am sorry that I am not (yet) able to fully understand and therefore explain it. But here is the code:

"let _art = [idArticle], _date = [Entry_date]
in
Table.FirstN(
Table.SelectRows(
Table.Sort( #"Table A", {{"Entry_date", Order.Descending}}), each [idArticle] = _art and [Entry_date] <= _date), 1
)"

 

 

 

  

View solution in original post

3 REPLIES 3
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @herbemischung ,

Have you solved your problem?

If you have solved, please always accept the replies making sense as solution to your question so that people who may have the same question can get the solution directly.

If you still need help, please share your data sample with table format and your desired output so that we could understand your logic better.

Best  Regards,

Cherry

 

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Yes, @Mariusz helped me with a formula. I am sorry that I am not (yet) able to fully understand and therefore explain it. But here is the code:

"let _art = [idArticle], _date = [Entry_date]
in
Table.FirstN(
Table.SelectRows(
Table.Sort( #"Table A", {{"Entry_date", Order.Descending}}), each [idArticle] = _art and [Entry_date] <= _date), 1
)"

 

 

 

  

Mariusz
Community Champion
Community Champion

Hi @herbemischung 

Can you create a data sample for both tables and one for the desired outcome.

 

Best Regards,
Mariusz

Please feel free to connect with me.
Mariusz Repczynski

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.