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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
GenZam1988
Frequent Visitor

Agrupar productos como una oferta

Hola favor ayuda en el siguiente caso:

 

Me piden agrupar los siguientes productos como una oferta en factura , los productos deben estar juntos en la misma factura para considerarse una oferta.

GenZam1988_0-1710907304001.png

 

En una tabla por factura se debe mostrar cuantas ofertas estaban presentes

GenZam1988_1-1710907414434.png

 

y poder decir cuantas ofertas fueron vendidas.

 

 

Saludos

 

1 ACCEPTED SOLUTION

Hi @GenZam1988 

Thanks for your reply.

Based on your description, you can refer to the following solution.

1.Remove the relationship between the tables(there is no relationship between the tables)

2.Create the following measures.

MEASURE =
VAR a =
    MAXX (
        FILTER ( 'Table', [Producto] = MAX ( 'Table (2)'[Articulo] ) ),
        [Oferta]
    )
VAR b =
    SUMMARIZE ( FILTER ( ALLSELECTED ( 'Table' ), [Oferta] = a ), [Producto] )
VAR c =
    CALCULATE (
        DISTINCTCOUNT ( 'Table (2)'[Articulo] ),
        ALLSELECTED ( 'Table (2)'[Articulo], 'Table (2)'[Numbero Factura] ),
        REMOVEFILTERS ( 'Table (2)'[Cantidad] ),
        'Table (2)'[Articulo] IN b,
        'Table (2)'[Numbero Factura] IN VALUES ( 'Table (2)'[Numbero Factura] )
    )
RETURN
    IF ( COUNTROWS ( b ) = c, a )
Measure2 =
CALCULATE (
    SUM ( 'Table (2)'[Cantidad] ),
    FILTER ( 'Table (2)', [Measure] IN VALUES ( 'Table'[Oferta] ) )
)

Output

vxinruzhumsft_0-1711090674405.png

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

3 REPLIES 3
v-xinruzhu-msft
Community Support
Community Support

Hi @GenZam1988 

Based on your description and the picture, you just need to create a relationship between the tables.

vxinruzhumsft_0-1710986167252.png

 

Then you can use a table visual to display the cantidads

vxinruzhumsft_1-1710986242015.png

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

Thanks for the reply.

 

But I need to find a way if the 2 products in the offer are together on the invoice it is considered an Offer, in the scenario that you tell me if there is only one product it is also taken as an offer.

 

It is mandatory that both products be together to be an offer

 

GenZam1988_1-1711039626100.png

 

Hi @GenZam1988 

Thanks for your reply.

Based on your description, you can refer to the following solution.

1.Remove the relationship between the tables(there is no relationship between the tables)

2.Create the following measures.

MEASURE =
VAR a =
    MAXX (
        FILTER ( 'Table', [Producto] = MAX ( 'Table (2)'[Articulo] ) ),
        [Oferta]
    )
VAR b =
    SUMMARIZE ( FILTER ( ALLSELECTED ( 'Table' ), [Oferta] = a ), [Producto] )
VAR c =
    CALCULATE (
        DISTINCTCOUNT ( 'Table (2)'[Articulo] ),
        ALLSELECTED ( 'Table (2)'[Articulo], 'Table (2)'[Numbero Factura] ),
        REMOVEFILTERS ( 'Table (2)'[Cantidad] ),
        'Table (2)'[Articulo] IN b,
        'Table (2)'[Numbero Factura] IN VALUES ( 'Table (2)'[Numbero Factura] )
    )
RETURN
    IF ( COUNTROWS ( b ) = c, a )
Measure2 =
CALCULATE (
    SUM ( 'Table (2)'[Cantidad] ),
    FILTER ( 'Table (2)', [Measure] IN VALUES ( 'Table'[Oferta] ) )
)

Output

vxinruzhumsft_0-1711090674405.png

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.