Seleccionar producto de mayor antiguedad

Hola!

En una app de INVENTARIO, necesito que al seleccionar un producto me informe el mes del producto mas antiguo en deposito.
Cada vez que ingresan productos de proveedores, se carga el part number, fecha, cantidad y descripcion de cada modelo.

Como hago para que cada vez que elijan un producto en una VENTA, aparezca una columna indicando de que FECHA o MES tiene que retirar del deposito.

Ejemplo de la idea deseada:

Nadie sabe como se hace? :pensive_face:

debes aplicar la funcion: sort , puedes crear una columna virtual con la siguiente formula cambiando LookupTable por el nombre de la tabla donde se encuentra la fecha y [ColumnC] cambiala por el nombre de la columna de fecha.

SORT(LookupTable[ColumnC])

Gracias @daniel_sanchez

Cree la columna virtual con la formula

SORT(DETALLE_COMPRAS[FECHA])

pero me muestra la fecha de todos los productos,

necesito diferenciarlo por [PART NUMBER]
La sintaxis SORT no me permite agregar 2 columnas

SORT(DETALLE_COMPRAS[FECHA],[PART NUMBER]) ERROR!

Do you have any referencing between the tables. If so, please share the relevant column names/ type details of the two tables (Key, reference column and part number, date etc that are likelyto be used in expressions)

1 Like

Thanks @Suvrutt_Gurjar
Yes, sure

TABLAS
------------

-INVENTARIO
[PART NUMBER] KEY

-VENTAS (tabla madre)
-DETALLE VENTAS (tabla hija)
[FECHA]
[PART NUMBER] Column REF INVENTARIO TABLE
[PRODUCTO]
[CANTIDAD]

-COMPRAS (tabla madre)
-DETALLE COMPRAS (tabla hija)
[FECHA]
[PART NUMBER] Column REF INVENTARIO TABLE
[PRODUCTO]
[CANTIDAD]

Thank you. Also please update if you can, on which column in which table you want to update. Sorry that since the names are in Spanish, it will help me to understand it faster, because I understand English. You need not translate all column names , just which column in which table from which column in which table.

I created a virtual column call [MONTH] type List in DETALLE VENTAS Table
Formula:

SORT(DETALLE_COMPRAS[FECHA])

The idea is when a user makes a sale, choose part number and in the virtual column [MONTH] show which is the oldest product or products in the warehouse.
When user sells, por example, 3 laptops, I need that virtual column [MONTH] show last 3 oldest, always depends of the quantity. With format ENE-23 / FEB-23 in date.
Every laptop in warehouse has a label with arrival month.

What is the column type [FECHA] in the two tables ? Because you have mentioned [MONTH} but that column does not seem to be in your list of columns and format you have mentioned is ENE-23 / FEB-23?

[FECHA] Type DATE in 2 tables (DETALLE_VENTAS) and (DETALLE_COMPRAS)
Date Format for default, 31/03/2023

[MONTH] is a virtual column only in DETALLE_VENTAS.
I want that [MONTH] format change to MAR-23, not 31/03/2023.

-VENTAS (tabla madre)
-DETALLE VENTAS (tabla hija)
[FECHA]
[PART NUMBER] Column REF INVENTARIO TABLE
[PRODUCTO]
[CANTIDAD]
[MONTH] Virtual column created to show old product month available in stock,
Is only an idea

Thank you.

Please try below.

In the table DETALLE_COMPRAS, create a text VC column [FECHA MONTH] with an expression something like TEXT([FECHA], “MMM-YY”)

In the table INVENTARIO, create a VC called say [Related COMPRAS BY FECHAS] with an expression something like

ORDERBY( [Related DETALLE _COMPRAS][Key of DETALLE COMPRAS Table], [FECHA], FALSE)

where [Related DETALLE _COMPRAS] is the reverse reference column in the INVENTARIO related to DETALLE _COMPRAS table. [FECHA] is date column name from the DETALLE _COMPRAS table.

Then create another VC called [Related DETALLE COMPRAS FECHAS] in the INVENTARIO table with an expression something like

[Related COMPRAS BY FECHAS][FECHA MONTH]

Then in the DETALLE_VENTAS table you could get dates in the FEB-23, MAR-23 format by using an expression [PART NUMBER].[Related DETALLE COMPRAS FECHAS]

1 Like

Thanks @Suvrutt_Gurjar
I understood VCs in INVENTARIO & DETALLE_COMPRAS tables, but..
I dont see any column in DETALLE_VENTAS table to show me older date product.

I need something like that (is only a edited picture)

RETIRAR DEL MES DE: (Show oldest products)
In this case last months are December-22 & January-23

You can get those dates in the DETALLE_VENTAS table in a list type column with app formula [PART NUMBER].[Related DETALLE COMPRAS FECHAS]

Thanks @Suvrutt_Gurjar

Works!, show every product with older months but I have a problem…
When users sells, for example: (3) laptops with months dic-22, dic-22, jan-23.
I need those months disappear with the sale, only show available products to sale.
Always show all months, products sold or not.

Well, please mention the names and type of columns in the three tables that indicate an item has been sold. In previous communication you did not mention this additional requirement ( of removing those dates as well as any column name that indicates the sell of the item. :slightly_smiling_face:

In general, you can remove the sold items dates by using the following expression

ORDERBY( SELECT([Related DETALLE _COMPRAS][Key of DETALLE COMPRAS Table], [Sold Status]= “Not Sold”), [FECHA], FALSE)

Where [Sold Status] is the column in the DETALLE _COMPRAS table that indicates the sale status of items. Please replace with the column name and proper status as it is configured in your app.

Thanks @Suvrutt_Gurjar

Sorry if I don’t explain the problem well, the main idea is that when a user selects a product to sell, a column tells him which is the oldest product in stock that he must remove.
This implies that the column only shows the available products, without the modification they would appear every month since the product exists in the company, it would be an endless list of months. It is also necessary that only the months equivalent to the number of products appear, for example, if the user selects 3 products, only the last 3 oldest months available should appear.

I perfectly understood the formula, the problem is that the app does not have a column that indicates that the product was sold or not.
The logic of the app is the following:

INVENTARIO = DETALLE_COMPRAS - DETALLE_VENTAS

INVENTARIO (Table)
[CANTIDAD] virtual column -

Use Next formula:

SUM(SELECT(DETALLE_COMPRAS[CANTIDAD],[PART NUMBER]=[_THISROW].[PART NUMBER]))- 
SUM(SELECT(DETALLE_VENTAS[CANTIDAD],[PART NUMBER]=[_THISROW].[PART NUMBER]))

Yes , in that case, I believe it is a real problem.

Could you please mention your idea, how can the app logic recognize, which record’s laptop has been sold, if there is no row level identification of the laptop sold. I assume, each record in the DETALLE_COMPRAS table has a record for each of the single item sold? Maybe you wish to share some sample pseudo data to describe how you have configured it.

If product is in DETALLE_VENTAS was sold, else is available.

INVENTARIO table have 2 virtual columns

[Related DETALLE_VENTASs] type list - REF DETALLE_VENTAS Table
REF_ROWS(“DETALLE_VENTAS”, “PART NUMBER”)

[Related DETALLE_COMPRASs] type list - REF DETALLE_COMPRAS Table
REF_ROWS(“DETALLE_COMPRAS”, “PART NUMBER”)

Thank you. I believe unless there is an identification of which month’s items have been sold in the “DETALLE_VENTAS” table, it may not be possible to delete those months. For example if an item has inventory available in months FEB-23, JAN-23 and Dec-22, how to know if and how much quantity is sold from DEC-22 or Jan-23 and so on.

Could you elaborate?

I dont understand when you say [SOLD STATUS] in the DETALLE_COMPRAS table, shouldn’t it be in the DETALLE_VENTAS table?
The DETALLE_VENTAS table is the one that records what has been sold.

When a user enters a product in the DETALLE_VENTAS table, that table has a [FECHA] column that records the month.

Is there a way to count the months according to the product? For example

Laptop
(10) DEC-22
(5) FEB-23

Mouse
(5) FEB-23
(9) MAR-23

I dont know, it’s just an idea.