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

Sum of values in column 1 if column 2 is equal

PBI.png

 

Hi All, I am new here and have a question about PowerBI

 

I like to have a measure ( if possible ) to calculate the sum from column 1 if the values in column 2 are equal.

 

I am new with PowerBI so I hope someone can help me.

7 REPLIES 7
v-xuding-msft
Community Support
Community Support

Hi @Roedie84 ,

You could try the following formula.

Measure = IF(MAX(column 1) = MAX(column 2), SUM(column 1),0)

If this is not what you want, can you please post some sample data and the excepted output?

Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

 

Best Regards,

Xue Ding

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

 

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
BekahLoSurdo
Resolver IV
Resolver IV

Hi @Roedie84,

 

Will this work?

CurrencyByDate = CALCULATE( 
    SUMX( 'Table', 'Table'[Currency Price] ),
    ALLEXCEPT( 'Table', 'Table'[Status31_Max_Date] ) 
)

This groups your currency values by date and gives the total sum of each group.

 

Best,

Bekah

Anonymous
Not applicable

Hi @Roedie84 , could you show your whole table (at least all the columns, not necessary all the lines) and the expected result ? 

 

I didn't understand what you're expecting from your screenshot

 

Regards, 

Etienne

 What I expect is:

 

For each date thats available in the column Status21_Max_Date a Sum of the Currency Price.

 

so if 29-07-2019 occurs 2 times with currency price 25 and 75 than the sum for 29-07-2019 = 100.

 

The possible solutions mentioned above don't work.

Hi @Roedie84 ,

I modified the formula you can have a try.

Measure = CALCULATE(SUM('Table'[Column2]),FILTER(ALL('Table'),'Table'[Column1] = MAX('Table'[Column1])))

23.PNG

Best Regards,

Xue Ding

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

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


@v-xuding-msft wrote:

Hi @Roedie84 ,

I modified the formula you can have a try.

Measure = CALCULATE(SUM('Table'[Column2]),FILTER(ALL('Table'),'Table'[Column1] = MAX('Table'[Column1])))

23.PNG

Best Regards,

Xue Ding

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


Thnx for your changed formula! Unfortunatly I get the following error Right now:

The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value.

 

Hi @Roedie84,

Have you tried the formula I posted? I think it is what you are looking for. Here it is modified with the sample information from this thread:

Measure = CALCULATE( 
    SUMX( 'Table', 'Table'[Column2] ),
    ALLEXCEPT( 'Table', 'Table'[Column1] ) 
)

SUMX.PNG

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.