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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

sum only some row in a column

Hi,

i need to sum a value column by an if condition like this

 

That's my DB example

image.png

 

I need to sum "Valore" column only if "ITEMID" & "VENDACCOUNT" (my key) have blank "FP Fornitore" only while there is at least 1 row that isn't blank.

Expected result: € 3630

 

So, if my "ITEMID" & "VENDACCOUNT" have an "FP Fornitore" i need the sum the rest

If my "ITEMID" & "VENDACCOUNT" don't have at least one row in "FP Fornitore" i will not sum

Another example:
image.png

Excepted result: 0

DB doesn't have any row with "FP Fornitore" by "ITEMID" & "VENDACCOUNT"

Last example:
image.png

Expected result: €1936

Hope that's a good explanation

Thanks!

1 ACCEPTED SOLUTION
v-juanli-msft
Community Support
Community Support

Hi @Anonymous 

Calculate measures

Capture1.JPG

Measure 2 =
VAR disc =
    CALCULATE (
        DISTINCTCOUNT ( 'Table'[VENDACCOUNT] ),
        ALLEXCEPT (
            'Table',
            'Table'[ITEMID]
        )
    )
VAR con =
    CONCATENATEX (
        FILTER (
            ALL ( 'Table' ),
            'Table'[ITEMID]
                = MAX ( 'Table'[ITEMID] )
        ),
        [FP fornitore]
    )
RETURN
    IF (
        disc > 1
            && con
                <> BLANK (),
        1
    )

Measure =
CALCULATE (
    SUM ( 'Table'[Valore] ),
    FILTER (
        ALLEXCEPT (
            'Table',
            'Table'[ITEMID]
        ),
        'Table'[FP fornitore]
            = BLANK ()
            && [Measure 2] = 1
    )
)

Best Regards
Maggie
Community Support Team _ Maggie Li
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-juanli-msft
Community Support
Community Support

Hi @Anonymous 

Calculate measures

Capture1.JPG

Measure 2 =
VAR disc =
    CALCULATE (
        DISTINCTCOUNT ( 'Table'[VENDACCOUNT] ),
        ALLEXCEPT (
            'Table',
            'Table'[ITEMID]
        )
    )
VAR con =
    CONCATENATEX (
        FILTER (
            ALL ( 'Table' ),
            'Table'[ITEMID]
                = MAX ( 'Table'[ITEMID] )
        ),
        [FP fornitore]
    )
RETURN
    IF (
        disc > 1
            && con
                <> BLANK (),
        1
    )

Measure =
CALCULATE (
    SUM ( 'Table'[Valore] ),
    FILTER (
        ALLEXCEPT (
            'Table',
            'Table'[ITEMID]
        ),
        'Table'[FP fornitore]
            = BLANK ()
            && [Measure 2] = 1
    )
)

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

The information you have provided is not making the problem clear to me. Can you please explain with an example.

Appreciate your Kudos.


Please Watch/Like/Share My webinar on Time Intelligence: https://community.powerbi.com/t5/Webinars-and-Video-Gallery/PowerBI-Time-Intelligence-Calendar-WTD-Y...
My Youtube Tips at: https://www.youtube.com/playlist?list=PLPaNVDMhUXGYrm5rm6ME6rjzKGSvT9Jmy

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

image.png

That's good i think

We bought item AX338 from F*096 and F*061 but we have the contract only with F*061, so the rest are "lost money" 

I need to sum the loss, yellow cells!

Anonymous
Not applicable

I need to see if we bought the same ITEM from different vendor, so i need to sum the value for each 

 

Cause we can buy item A from vendor X and item A from vendor Y, maybe Y vendor has a better contract ( column "FP Fornitore"), so i need to sum the value that we lost with the other vendor X

 

While, if we buy item A only from one seller there is no problem!

 

Hope that's better

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Top Solution Authors