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
jimpatel
Post Patron
Post Patron

Combine according to condition

Hi,

Thanks for looking at my post.

 

I am looking for dax formula to do the below please?

Any help will be much appreciated 

 

I have year/month and name column and i wanted to combine the "Total" according to Year/Month and if is in "Name1,Name3 or Name5" and ignore the rest

 

Any idea please?

 

Thanks a lot 

jimpatel_0-1713260500368.png

 

1 ACCEPTED SOLUTION

You need to reference the Year column so it should be

Earlier('Table1'[Year])


Please change out the Table1 part to the actual name of your table




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

Proud to be a Super User!





Learn about the Star Schema, it will solve many issues in Power BI!

Date tables help! Learn more



LinkedIn
Let's connect on LinkedIn


View solution in original post

6 REPLIES 6
jimpatel
Post Patron
Post Patron

Perfect. Thanks a lot 🙂

jimpatel
Post Patron
Post Patron

Hi,

 

Thanks a lot for your reply.

 

May i know do i need to create second table for this measure? Can we not do it in the same table?

 

Thanks a lot again

 

Expected Result = 
IF( Table1[Name] in {"Name4", "Name2"} , BLANK(), 
CALCULATE(
SUM(Table1[Total]), 
FILTER('Table1', 
   'Table1'[Year] = Earlier('Table1'[Year]) && 
   'Table1'[Month] = Earlier('Table1'[Month]) &&
   'Table1'[Name] in  {"Name1", "Name3", "Name5"})))

 

This should work, add a custom column and this measure




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

Proud to be a Super User!





Learn about the Star Schema, it will solve many issues in Power BI!

Date tables help! Learn more



LinkedIn
Let's connect on LinkedIn


Thanks a lot for your time.

 

I am getting error in Earlier any idea please?

 

jimpatel_0-1713269981033.png

 

You need to reference the Year column so it should be

Earlier('Table1'[Year])


Please change out the Table1 part to the actual name of your table




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

Proud to be a Super User!





Learn about the Star Schema, it will solve many issues in Power BI!

Date tables help! Learn more



LinkedIn
Let's connect on LinkedIn


Joe_Barry
Super User
Super User

Hi @jimpatel 

 

Dax solution

 

In the second table add a column and enter this measure

Expected Result =
CALCULATE (
    SUM('Table1'[Total]), 
    FILTER (
        'Table1',
        'Table1' [Year] = 'Table2'[Year] &&
        'Table1' [Month] = 'Table2'[Month] &&
        'Table1' [Name] in  {"Name1, "Name3", "Name5"}
)

 

Joe

 

If you found my answer helpful and it solved your issue, please accept as solution




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

Proud to be a Super User!





Learn about the Star Schema, it will solve many issues in Power BI!

Date tables help! Learn more



LinkedIn
Let's connect on LinkedIn


Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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