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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Oleh
New Member

CALCULATE function based on criteria referring to two columns in one table

Hi All,

 

I have the following input data and need to calulte column Result using DAX.

 

MonthValueID_1ID_2Result
January              12a 0
February              14a 0
March                5b 0
April                7b 0
May                8b 0
June                1c 0
July              41b 0
August              24 a26
September              33 b61

 

In excel I would simply using SUMIFS with criteria range as column "ID_1" and criteria as column "ID_2":Capture.PNG

In DAX I am trying to make the following:

Result = if('Sample'[ID_2] = "", 0 , CALCULATE ( sum ('Sample'[Value]), FILTER ( 'Sample' , 'Sample'[ID_1] = 'Sample'[ID_2] ) ) )
 
But it does not produce result I expect.
 
Can you please advise how can I properly build DAX expression?
 
Thank you in advance,
best regards,
Oleh
1 ACCEPTED SOLUTION
nvprasad
Solution Sage
Solution Sage

Hi,

Can you try below formula 🙂

Result =
Var currntrow = abcd[ID_2]
RETURN
IF(abcd[ID_2]=BLANK(),0,CALCULATE(sum(abcd[Value]),FILTER(abcd,abcd[ID_1]=currntrow)))
 

Appreciate a Kudos! 🙂
If this helps and resolves the issue, please mark it as a Solution! 🙂

Regards,
N V Durga Prasad

 

 

Did I answer your question? Mark my post as a solution! Appreciate your Kudos.
Follow me on LinkedIn.

View solution in original post

2 REPLIES 2
nvprasad
Solution Sage
Solution Sage

Hi,

Can you try below formula 🙂

Result =
Var currntrow = abcd[ID_2]
RETURN
IF(abcd[ID_2]=BLANK(),0,CALCULATE(sum(abcd[Value]),FILTER(abcd,abcd[ID_1]=currntrow)))
 

Appreciate a Kudos! 🙂
If this helps and resolves the issue, please mark it as a Solution! 🙂

Regards,
N V Durga Prasad

 

 

Did I answer your question? Mark my post as a solution! Appreciate your Kudos.
Follow me on LinkedIn.

Big thank you! It works!

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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