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
Syndicate_Admin
Administrator
Administrator

ADDING ONE WITH CONDITIONS

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

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] )
)









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


Proud to be a Super User!









"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

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

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.

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

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.










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


Proud to be a Super User!









"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

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] )
)









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


Proud to be a Super User!









"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.

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!

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.