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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
AnnaAliera18
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)
 
AnnaAliera18_0-1658832856728.png

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.

 

AnnaAliera18_1-1658833120598.png

 

 

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
v-jianboli-msft
Community Support
Community Support

Hi @AnnaAliera18 ,

 

Please try:

 

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

 

Output:

vjianbolimsft_0-1659091677756.png

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.

View solution in original post

3 REPLIES 3
v-jianboli-msft
Community Support
Community Support

Hi @AnnaAliera18 ,

 

Please try:

 

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

 

Output:

vjianbolimsft_0-1659091677756.png

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.

amitchandak
Super User
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])

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thanks the error is gone but the calculation is wrong. 

the Total gets 5 

AnnaAliera18_0-1658843906846.png

 

 

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. 

Thanks for your help 🙂 

Helpful resources

Announcements
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.