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
n2p2gupta
Frequent Visitor

Adding values based on condition from two different columns

I need to create a new column by looking up distinct values from "Bid Number" and "Class" and sum up the "bid value" in the new column.  Any help is greatly appreciated.

 

for example: I want to create "Bid value total" column  based on unique values where "Bid Number" & "class" are same.

 

Bid Number   Bid value   class   Bid value total

151                  10             a

151                  10             a           20

151                  10             b        

151                   5              b           15

152                  10             b

152                  20             b           30

1 ACCEPTED SOLUTION
Eric_Zhang
Employee
Employee


@n2p2gupta wrote:

I need to create a new column by looking up distinct values from "Bid Number" and "Class" and sum up the "bid value" in the new column.  Any help is greatly appreciated.

 

for example: I want to create "Bid value total" column  based on unique values where "Bid Number" & "class" are same.

 

Bid Number   Bid value   class   Bid value total

151                  10             a

151                  10             a           20

151                  10             b        

151                   5              b           15

152                  10             b

152                  20             b           30


@n2p2gupta

You can either create a calculated column

bid value total colum =
CALCULATE (
    SUM ( yourTable[Bid value] ),
    FILTER (
        yourTable,
        EARLIER ( yourTable[Bid Number] ) = yourTable[Bid Number]
            && EARLIER ( yourTable[class] ) = yourTable[class]
    )
)

Capture.PNG

 

Or create a measure and put data in a Table visual.

 

bid value total measure =
CALCULATE (
    SUM ( yourTable[Bid value] ),
    ALLEXCEPT ( yourTable, yourTable[Bid Number], yourTable[class] )
)

Capture.PNG

View solution in original post

2 REPLIES 2
Eric_Zhang
Employee
Employee


@n2p2gupta wrote:

I need to create a new column by looking up distinct values from "Bid Number" and "Class" and sum up the "bid value" in the new column.  Any help is greatly appreciated.

 

for example: I want to create "Bid value total" column  based on unique values where "Bid Number" & "class" are same.

 

Bid Number   Bid value   class   Bid value total

151                  10             a

151                  10             a           20

151                  10             b        

151                   5              b           15

152                  10             b

152                  20             b           30


@n2p2gupta

You can either create a calculated column

bid value total colum =
CALCULATE (
    SUM ( yourTable[Bid value] ),
    FILTER (
        yourTable,
        EARLIER ( yourTable[Bid Number] ) = yourTable[Bid Number]
            && EARLIER ( yourTable[class] ) = yourTable[class]
    )
)

Capture.PNG

 

Or create a measure and put data in a Table visual.

 

bid value total measure =
CALCULATE (
    SUM ( yourTable[Bid value] ),
    ALLEXCEPT ( yourTable, yourTable[Bid Number], yourTable[class] )
)

Capture.PNG

Thanks Eric!

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.