Reply
Syndicate_Admin
Administrator
Administrator
Syndicated - Inbound

ADDING ONE WITH CONDITIONS

Source Community: Power BI Spanish | Source Author Name: Txitxilo

Good morning

I want to add the "UNITS" column according to product, color and size per agent.

Txitxilo_0-1723630565503.png

For example, Luis, 3 units, but it doubles me in this case to 6 units by the supplier.

Another example, Pedro, 30 units.

Thank you!

2 ACCEPTED SOLUTIONS
danextian
Super User
Super User

Syndicated - Outbound

Hi @Syndicate_Admin 

If you want to calculate the sum of units by agent and supplier, try this:

CALCULATE (
    SUM ( 'table'[UNIDADES] ),
    ALLEXCEPT ( 'table', 'table'[AGENTE], 'table'[PROVEEDOR] )
)




Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

v-jiewu-msft
Community Support
Community Support

Syndicated - Outbound

Hi @Syndicate_Admin ,

Based on my testing, please try the following methods:

1.Create the sample table.

vjiewumsft_0-1724119568776.png

2.Create the calculated table.

Unique = SUMMARIZE(
       'Table', 
       'Table'[AGENT], 
       'Table'[PRODUCT], 
       'Table'[COLOR], 
       'Table'[SIZE], 
       "UniqueUnits", MAX('Table'[UNIDADES])
   )

3.Create the relationship between two tables.

4.Create the new Units column.

Units = 
CALCULATE(
           SUM('Unique'[UniqueUnits]), 
           ALLEXCEPT('Unique', 'Unique'[AGENT])
       )

5.The result is shown below.

vjiewumsft_2-1724119629576.png

Best Regards,

Wisdom Wu

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

4 REPLIES 4
v-jiewu-msft
Community Support
Community Support

Syndicated - Outbound

Hi @Syndicate_Admin ,

Based on my testing, please try the following methods:

1.Create the sample table.

vjiewumsft_0-1724119568776.png

2.Create the calculated table.

Unique = SUMMARIZE(
       'Table', 
       'Table'[AGENT], 
       'Table'[PRODUCT], 
       'Table'[COLOR], 
       'Table'[SIZE], 
       "UniqueUnits", MAX('Table'[UNIDADES])
   )

3.Create the relationship between two tables.

4.Create the new Units column.

Units = 
CALCULATE(
           SUM('Unique'[UniqueUnits]), 
           ALLEXCEPT('Unique', 'Unique'[AGENT])
       )

5.The result is shown below.

vjiewumsft_2-1724119629576.png

Best Regards,

Wisdom Wu

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

Source Community: Power BI Spanish | Source Author Name: Txitxilo
Syndicated - Inbound

Hello

First thank you for your message.

The results I want to get are the total units that I consult with the suppliers.

that is, in the 240801 consultation, agent Luis requests prices of 2 large red notebooks and 1 small green pencil. In total, Luis asks for a quote for 3 units from two different suppliers.

When adding the units in PowerBi it adds as many units as suppliers I have consulted. In this case it adds up to the 6 units because I have consulted two suppliers, but in reality I only consult 3 units (2 notebooks + 1 pencil).

Thank you

Syndicated - Outbound

Hi @Syndicate_Admin ,

 

If you want to the units to counted just once by Agent, Product, Color and Size,  use SUMX and SUMMARIZE in a measure.

Sum of Units = 
SUMX (
    SUMMARIZE (
        'Table',
        'Table'[ID],
        'Table'[AGENT],
        'Table'[PRODUCT],
        'Table'[COLOR],
        'Table'[SIZE],
        'Table'[UNIDADES]
    ),
    [UNIDADES]
)

danextian_0-1725617392329.png

Please see the attached pbix.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
danextian
Super User
Super User

Syndicated - Outbound

Hi @Syndicate_Admin 

If you want to calculate the sum of units by agent and supplier, try this:

CALCULATE (
    SUM ( 'table'[UNIDADES] ),
    ALLEXCEPT ( 'table', 'table'[AGENTE], 'table'[PROVEEDOR] )
)




Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
avatar user

Helpful resources

Announcements
March PBI video - carousel

Power BI Monthly Update - March 2025

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

March2025 Carousel

Fabric Community Update - March 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors (Last Month)
Top Kudoed Authors (Last Month)