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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
holodan95
Helper II
Helper II

Return the last price of an item at specific store, by date

Hello All,

Please help me with returning the latest price of an item at a specific store from one table to another's column (table from SQL source, not a matrix visual)

 

In Table1 from SQL I have inventory information like:

Date / StoreID / itemID / Qty

22.11.2022 / store1 / item1 / 13 pieces

22.11.2022 / store2 / item1 / 10 pieces

22.11.2022 / store1 / item2 / 5 pieces

 

In Table2 from SQL I have sale prices like:

Date / StoreID / ItemID / UnitPrice

11.11.2022 / store1 / item1 / €3/unit

10.11.2022 / store1 / item1 / €5/unit

01.11.2022 / store2 / item1 / €4,5/unit

01.11.2022 / store1 / item2 / €4/unit

...

 

What I want to achieve is to return the last sales price of the items in Table1 into a new column.

 

The result should look like this in Table1:

Date / StoreID / itemID / Qty / UnitPrice

22.11.2022 / store1 / item1 / 13 pieces / €3

22.11.2022 / store2 / item1 / 10 pieces / €4,5

22.11.2022 / store1 / item2 / 5 pieces / €4

 

It's important that each item in a specific store will have a uniqe price for the last date.

 

Thank you!

1 ACCEPTED SOLUTION
ryan_mayu
Super User
Super User

@holodan95 

you can try this to create a column

Column = 
var _date=maxx(FILTER(Table2,Table1[storeID]=Table2[store]&&Table1[ItemID]=Table2[item]&&'Table1'[date]>='Table2'[date]),'Table2'[date])
return maxx(FILTER(Table2,Table1[storeID]=Table2[store]&&Table1[ItemID]=Table2[Item]&&'Table2'[date]=_date),Table2[unitprice])

1.PNG

pls see the attachment below





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

3 REPLIES 3
ryan_mayu
Super User
Super User

@holodan95 

you can try this to create a column

Column = 
var _date=maxx(FILTER(Table2,Table1[storeID]=Table2[store]&&Table1[ItemID]=Table2[item]&&'Table1'[date]>='Table2'[date]),'Table2'[date])
return maxx(FILTER(Table2,Table1[storeID]=Table2[store]&&Table1[ItemID]=Table2[Item]&&'Table2'[date]=_date),Table2[unitprice])

1.PNG

pls see the attachment below





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hi,

Thank you!

 

Column = 
var _date=maxx(FILTER(Table2,Table1[storeID]=Table2[store]&&Table1[ItemID]=Table2[item]&&'Table1'[date]>='Table2'[date]),'Table2'[date])
return maxx(FILTER(Table2,Table1[storeID]=Table2[store]&&Table1[ItemID]=Table2[Item]&&'Table2'[date]=_date),Table2[unitprice])

 

you are welcome





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.