cancel
Showing results for
Did you mean:

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a \$100 discount. Register Now

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.

 Month Value ID_1 ID_2 Result January 12 a 0 February 14 a 0 March 5 b 0 April 7 b 0 May 8 b 0 June 1 c 0 July 41 b 0 August 24 a 26 September 33 b 61

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

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.

best regards,
Oleh
1 ACCEPTED SOLUTION
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,

2 REPLIES 2
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,

New Member

Big thank you! It works!

Announcements

#### Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

#### Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

#### Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

#### Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors
Top Kudoed Authors