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
mmoroni
Helper I
Helper I

calculate sum if 2 columns match

In a nutshell, here's what I am in need of help with.  I need a column to:
if channel # is NOT 1000

'channel name' is the same as row (earlier)

AND 'date' is the same as row,

SUM 'Total Min'

 

mmoroni_0-1612192593820.png

 

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

Hi @mmoroni ,

 

Based on your description, you can create a calculated column as follows.

Column = CALCULATE(SUM(channel[Total Min]),'channel'[Channel #]<>1000,ALLEXCEPT(channel,channel[Channel Name],channel[Date]))
Result:

v-yuaj-msft_0-1612321395688.png

Do you want to match columns between two different tables? If so, you can try the LOOKUPVALUE() function.

 

Hope that's what you were looking for.

Best Regards,

Yuna

 

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

6 REPLIES 6
v-yuaj-msft
Community Support
Community Support

Hi @mmoroni ,

 

I added the data in the screenshot and tested it. The DAX function of a calculated column is the same as mentioned above.

Is the following result what you want?

([only "29"+"529"]+[same date"12/29/2020"]+[same channel "ESPN MD"]----->1379+66497=67876)

v-yuaj-msft_0-1612424632395.png

 

Hope that's what you were looking for.

Best Regards,

Yuna

 

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

Well......  call me silly.  I must have had something wrong in my trial of the formula.

Combined channel name Total Mins = CALCULATE(SUM('Viewership_By_Day_-_Monthly'[Total Min]),'Viewership_By_Day_-_Monthly'[Channel #]<>1000,ALLEXCEPT('Viewership_By_Day_-_Monthly','Viewership_By_Day_-_Monthly'[Channel Name],'Viewership_By_Day_-_Monthly'[Date]))

  Looks like it is working the way I need it.  Thank you! 

v-yuaj-msft
Community Support
Community Support

Hi @mmoroni ,

 

Based on your description, you can create a calculated column as follows.

Column = CALCULATE(SUM(channel[Total Min]),'channel'[Channel #]<>1000,ALLEXCEPT(channel,channel[Channel Name],channel[Date]))
Result:

v-yuaj-msft_0-1612321395688.png

Do you want to match columns between two different tables? If so, you can try the LOOKUPVALUE() function.

 

Hope that's what you were looking for.

Best Regards,

Yuna

 

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

 

Not quite...  Perhaps my example should be more clear.  So my apologies on that.

In the below, we see Channel # 29, 529, 1000 - All for ESPN HD and all on the same DATE (12/29/2020).

I would like the new column to add the Total Min for 29 and 529 (based on the channel name) when they are both on the same date.  But EXCLUDE counting in channel number 1000 - even though its the same name and the same date.
So... Calculate(SUM(IF( Channel name = earlier (channel name) AND(Date = Earlier(date), except if channel number <>1000.

mmoroni_0-1612388084174.png

 

 

pranit828
Community Champion
Community Champion

Hi @mmoroni 

Calculate(sum('table'[total min]), allexcept('table','table'[channel name]),'table'[channel name]<> 1000)





PBI_SuperUser_Rank@1x.png


Hope it resolves your issue? 
Did I answer your question? Mark my post as a solution!

Appreciate your Kudos, Press the thumbs up button!!
Linkedin Profile

Not quite there.  I need that if the DATE is the same, AND the channel name is the same, to sum the minutes.  But thank you for the valiant try.

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.

Top Solution Authors