cancel
Showing results for
Did you mean:
New Member

## summarizecolumns and if statement

Hello,

something I don't understand.

I want count a if statement with two columns.

Test = if(sum('Table'[Column1]) >0 && sum('Table'[Column2])>0,1,0)

What I want is the Sum of Test. I'll tried this.

test2 = var table1 = SUMMARIZECOLUMNS('Table'[AccountID],"Sum",if(sum('Table'[Column1]) >0 && sum('Table'[Column2])>0,1,0)) return sumx(table1,[Sum])

But I'll get an error if i want show it together with AccountId.

Is there somebody who could explain me this behaviour of DAX 🙂

I don't understand why I can't use AccountId with this measure.

Thanks and take care,

Anna

1 ACCEPTED SOLUTION
Community Support

``test = SUMX(ADDCOLUMNS('Table',"SUM",IF([Column1]>0&&[Column2]>0,1,0)),[SUM])``

Output:

Best Regards,

Jianbo Li

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

3 REPLIES 3
Community Support

``test = SUMX(ADDCOLUMNS('Table',"SUM",IF([Column1]>0&&[Column2]>0,1,0)),[SUM])``

Output:

Best Regards,

Jianbo Li

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

Super User

@AnnaAliera18 , Use summarize with Addcolumns

test2 = var table1 = Addcolumns(Summarize('Table', 'Table'[AccountID]) ,"Sum",if(sum('Table'[Column1]) >0 && sum('Table'[Column2])>0,1,0))
return sumx(table1,[Sum])

Learn Power BI - Full Course with Dec-2022, with new DAX functions like Window, Index, Offset !!
Did I answer your question? Mark my post as a solution! Appreciate your Kudos !! Proud to be a Super User! !!
Formatted Profit and Loss Statement with empty lines
New Member

Thanks the error is gone but the calculation is wrong.

the Total gets 5

how  I can get 3 in my total?

What I want is sum the 1 in the column. If I use a physical table it works fine, but i want use a VAR and only one measure if it works.

Announcements

#### 2023 Release Wave 1 Plans

Power BI release plans for 2023 release wave 1 describes all new features releasing from April 2023 through September 2023.

#### Global Power BI Training

Make sure you register today for the Power BI Summit 2023. Don't miss all of the great sessions and speakers!

#### 2022 Monthly Feature Releases

We had a great 2022 with a ton of feature releases to help you drive a data culture.

Top Solution Authors
Top Kudoed Authors