cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Manuu_108
Frequent Visitor

REGISTRO DE PRODUCTOS PRESTADOS Y DEVUELTOS

Buenas Noches recurro a su conocimiento para el siguiente reto.
Tengo una tabla donde se registra todos los productos prestados y que tienen que ser devueltas, las celdas marcadas con rojo, azul y verde que corresponde a Ana Maria, Daniela  y Mariela quienes se prestaron y devolvieron, por lo tanto no figuran en el reporte filtrado.

En el caso de Sofia ( marcado con amarillo) hubo 3 ocurrencias en un mismo dia:
1.- Se prestó el producto P301 a hrs: 11:30 am

2.- Se devolvio el producto P301 a hrs: 14:40 pm

3.- y por ultimo, se prestó nuevamente el mismo producto a hrs: 17:55 pm

Por lo cual en el resporte debe mostrar la ÚLTIMA OCURRENCIA en este caso, Sofia queda pendiente de devolucion del producto P301.

(Envio archivo de ejemplo)
https://docs.google.com/spreadsheets/d/1AHtJl03i65wdRILZ69BG2MP2FBdf4vc6/edit?usp=sharing&ouid=11185...
aa1.jpgFB6.jpg

1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

Hi @Manuu_108 

 

Here is my solution:

First add a calculated column to the original table with below DAX. This is to get the product name on each row. 

Producto = MAX('Table'[Producto Entregado],'Table'[Producto Devuelto])

vjingzhang_0-1675928890762.png

Then create a calculated table with below DAX to get the expected result with data from the original table. The sample file has been attached at bottom. 

Table 2 = 
SELECTCOLUMNS (
    FILTER (
        SUMMARIZE (
            'Table',
            'Table'[Nombre],
            'Table'[Producto],
            "count_of_entregado",
                CALCULATE (
                    COUNT ( 'Table'[Producto Entregado] ),
                    'Table'[Producto Entregado] <> BLANK ()
                ),
            "count_of_devuelto",
                CALCULATE (
                    COUNT ( 'Table'[Producto Devuelto] ),
                    'Table'[Producto Devuelto] <> BLANK ()
                ),
            "Fecha Prestada", MAX ( 'Table'[Fecha] )
        ),
        [count_of_entregado] > [count_of_devuelto]
    ),
    "Fecha Prestada", [Fecha Prestada],
    "Name", [Nombre],
    "Situacion", "Con Observacion",
    "Producto Prestado", [Producto],
    "Dias Prestados", INT ( TODAY() - [Fecha Prestada] ) & " Dias"
)

vjingzhang_2-1675930056864.png

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

View solution in original post

1 REPLY 1
v-jingzhang
Community Support
Community Support

Hi @Manuu_108 

 

Here is my solution:

First add a calculated column to the original table with below DAX. This is to get the product name on each row. 

Producto = MAX('Table'[Producto Entregado],'Table'[Producto Devuelto])

vjingzhang_0-1675928890762.png

Then create a calculated table with below DAX to get the expected result with data from the original table. The sample file has been attached at bottom. 

Table 2 = 
SELECTCOLUMNS (
    FILTER (
        SUMMARIZE (
            'Table',
            'Table'[Nombre],
            'Table'[Producto],
            "count_of_entregado",
                CALCULATE (
                    COUNT ( 'Table'[Producto Entregado] ),
                    'Table'[Producto Entregado] <> BLANK ()
                ),
            "count_of_devuelto",
                CALCULATE (
                    COUNT ( 'Table'[Producto Devuelto] ),
                    'Table'[Producto Devuelto] <> BLANK ()
                ),
            "Fecha Prestada", MAX ( 'Table'[Fecha] )
        ),
        [count_of_entregado] > [count_of_devuelto]
    ),
    "Fecha Prestada", [Fecha Prestada],
    "Name", [Nombre],
    "Situacion", "Con Observacion",
    "Producto Prestado", [Producto],
    "Dias Prestados", INT ( TODAY() - [Fecha Prestada] ) & " Dias"
)

vjingzhang_2-1675930056864.png

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

Helpful resources

Announcements
March 2023 Update3

Power BI March 2023 Update

Find out more about the March 2023 update.

Power BI Dev Camp Session 32

Ted's Dev Camp - March 30, 2023

In this session, we'll examine important design issues and decisions that arise when developing with Power BI embedding.

Top Solution Authors