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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
jibran
Helper II
Helper II

If statement with count

Hi Dev,

I am trying to write a DAX query that shows me value of 0. if sum of debit side of a vehicle equals to the credit side of that period.

My formula is below but it comes with an error

Equal = IF(Sum(Query1[F_NOM_DEBIT]) = SUM(Query1[F_NOM_CREDIT]),
	Format(0,ALLEXCEPT(Query1,Query1[F_NOM_VEH_ID],Query1[F_NOM_PERIOD])),
	-1)

But it comes with error "The expression refers to multiple columns. Multiple columns cannot be coverted to a scalar value"

 

if with pi and si.JPG

So where it matches the total value of a specific ID example 10157 it should show 0 and where not it should show -1

 

Many Thanks 

 

Jibran 

 

1 ACCEPTED SOLUTION
v-qiuyu-msft
Community Support
Community Support

Hi @jibran,

 

Please try to create a measure like below:

 

Equal = IF(CALCULATE(SUM(Table1[F_NOM_ CREDIT]), ALLEXCEPT(Table1,'Table1'[F_NOM_VEH_ID],'Table1'[F_NOM_PERIOD]))=CALCULATE(SUM(Table1[F_NOM_DEBIT]), ALLEXCEPT(Table1,'Table1'[F_NOM_VEH_ID],Table1[F_NOM_PERIOD])),
	0,-1)

 

Best Regards,
Qiuyun Yu 

Community Support Team _ Qiuyun Yu
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

2 REPLIES 2
v-qiuyu-msft
Community Support
Community Support

Hi @jibran,

 

Please try to create a measure like below:

 

Equal = IF(CALCULATE(SUM(Table1[F_NOM_ CREDIT]), ALLEXCEPT(Table1,'Table1'[F_NOM_VEH_ID],'Table1'[F_NOM_PERIOD]))=CALCULATE(SUM(Table1[F_NOM_DEBIT]), ALLEXCEPT(Table1,'Table1'[F_NOM_VEH_ID],Table1[F_NOM_PERIOD])),
	0,-1)

 

Best Regards,
Qiuyun Yu 

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi,

 

Thanks for the help I was away from the office it has worked, but can I use filter for example show me only -1 related data or show me 0 related data.

 

Many Thanks 

 

Jibran

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.