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
PeterStuhr
Helper V
Helper V

Añadir recuento y suma a la tabla en función de varios ifs

Hola a todos

Tenemos una "Tabla de Descuento" que se parece un poco a esto:

IdproveedorLanguageidProductTypeIDWorkAreaIDDiscountSettings
111150%
121250%
121150%
131250%

Luego tenemos una "tabla de ventas" que se parece un poco a esto:

JobIDPrecioIdproveedorLanguageidProductTypeIDWorkAreaID
1001001111
1011001212
1021001312
1031001312
1041001211
1051001111
1061001211
1071001211
1081001312
1091001212
1101001212

Me gustaría obtener un "Recuento de trabajos" y "Precio" para cada "Configuración" basado en la primera tabla.

Así que me gustaría una salida algo así:

IdproveedorLanguageidProductTypeIDWorkAreaIDDiscountSettingsNúmero de trabajosPrecio
111150%2200
121250%3300
121150%3300
131250%3

300

No estoy seguro de cómo combinar las tablas sin una "clave única".

Por lo tanto, un ejemplo para mí sería conocer el "Precio" y "Recuento de trabajos" para cada SupplierID-1, donde LanguageID-1, ProductTypeID-1, WorkAreaID-1 y DiscountSettings-50%.

Y entonces sólo necesitaría todas las combinaciones posibles.

¡Por favor, ayúdenme! 🙂

1 ACCEPTED SOLUTION
V-lianl-msft
Community Support
Community Support

Hola @PeterStuhr ,

Intente crear medidas como las siguientes:

Price =
CALCULATE (
    SUM ( 'Table (2)'[Price] ),
    FILTER (
        'Table (2)',
        'Table (2)'[SupplierID] = MAX ( 'Table'[SupplierID] )
            && 'Table (2)'[ProductTypeID] = MAX ( 'Table'[ProductTypeID] )
            && 'Table (2)'[WorkAreaID] = MAX ( 'Table'[WorkAreaID] )
            && 'Table (2)'[LanguageID] = MAX ( 'Table'[LanguageID] )
    )
)

Job count=
CALCULATE (
    COUNT( 'Table (2)'[JobId] ),
    FILTER (
        'Table (2)',
        'Table (2)'[SupplierID] = MAX ( 'Table'[SupplierID] )
            && 'Table (2)'[ProductTypeID] = MAX ( 'Table'[ProductTypeID] )
            && 'Table (2)'[WorkAreaID] = MAX ( 'Table'[WorkAreaID] )
            && 'Table (2)'[LanguageID] = MAX ( 'Table'[LanguageID] )
    )
)

test_Add Count and Sum to table based on multiple ifs.PNG

Saludos
Liang
Si este post ayuda, entonces considera Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.

View solution in original post

3 REPLIES 3
V-lianl-msft
Community Support
Community Support

Hola @PeterStuhr ,

Intente crear medidas como las siguientes:

Price =
CALCULATE (
    SUM ( 'Table (2)'[Price] ),
    FILTER (
        'Table (2)',
        'Table (2)'[SupplierID] = MAX ( 'Table'[SupplierID] )
            && 'Table (2)'[ProductTypeID] = MAX ( 'Table'[ProductTypeID] )
            && 'Table (2)'[WorkAreaID] = MAX ( 'Table'[WorkAreaID] )
            && 'Table (2)'[LanguageID] = MAX ( 'Table'[LanguageID] )
    )
)

Job count=
CALCULATE (
    COUNT( 'Table (2)'[JobId] ),
    FILTER (
        'Table (2)',
        'Table (2)'[SupplierID] = MAX ( 'Table'[SupplierID] )
            && 'Table (2)'[ProductTypeID] = MAX ( 'Table'[ProductTypeID] )
            && 'Table (2)'[WorkAreaID] = MAX ( 'Table'[WorkAreaID] )
            && 'Table (2)'[LanguageID] = MAX ( 'Table'[LanguageID] )
    )
)

test_Add Count and Sum to table based on multiple ifs.PNG

Saludos
Liang
Si este post ayuda, entonces considera Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.

parry2k
Super User
Super User

@PeterStuhr concatenar columnas para crear una clave suplente para establecer la relación entre tablas y, a continuación, puede obtener datos de la tabla con bastante facilidad.

Me gustaría elogiossi mi solución ayudara.👉Si puedes pasar tiempo publicando la pregunta, también puedes hacer esfuerzos para dar a Kudos quien haya ayudado a resolver tu problema. ¡Es una muestra de agradecimiento!

Visítenos enhttps://perytus.com, su ventanilla única para proyectos/formación/consulta relacionados con Power BI.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Hola @parry2k

¿Puedes mostrarme cómo lo harías?

¡Soy bastante nuevo en esto!

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.