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
Anonymous
Not applicable

PowerBI if condition not working

It return all record with 0  

 

IF(SUM(Opportunity[Month]) in {1,2,3,4,5,6, 7} , ( SUM('August 2019'[Revenue]) - SUM('2018 Invoice'[Revenue])) , 0)

 

if month is select 1 to 7 it should show this calculation otherwise should return 0

1 ACCEPTED SOLUTION
jthomson
Solution Sage
Solution Sage

Don't know why you don't reword it as if (Opportunity[Month]<8), not sure why there's a sum there at all and it looks much cleaner

View solution in original post

7 REPLIES 7
v-chuncz-msft
Community Support
Community Support

@Anonymous 

 

Values in a calculated column are fixed. Make sure it is a measure.

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
GetResponsive
Regular Visitor

Hi @Anonymous 

 

The SUM should not be before Opportunity[Month] indeed.

 

In addition: I see you using 3 different tables. Best is to have 1 table with the dates. And to have your various tables linked into this date table. Then you can use the month from the date table for your IF statement

 

Hope this helps

 

BR

 

Jeroen Heerschop

Get Responsive

Anonymous
Not applicable

If I remove Sum then I am not able to locate this column. Moreover all 3 tables are connected using month column and I need to calculate from different table values. is there any other way ? 

Hi @Anonymous 

 

Try to use MIN instead of SUM. It depends on context that you are using this formula in. Furthermore if you connected on month, is there a table with months/dates that linked the 3 tables into? You should use that month table as input for your calculation.

 

Can you maybe share a part of your pbix? That makes it easier to answer.

 

BR

 

Jeroen Heerschop

Get Responsive

jthomson
Solution Sage
Solution Sage

Don't know why you don't reword it as if (Opportunity[Month]<8), not sure why there's a sum there at all and it looks much cleaner

GetResponsive
Regular Visitor

hi @Anonymous 

 

did you make sure that Opportunity[Month] has a type of (whole) number and not text. You can recognize this if in the fieldlist no sigma icon is noted before the field name. In the (Power) Query Editor you can change the type to number. 

 

BR

 

Jeroen Heerschop

Get Responsive

Anonymous
Not applicable

for Month I have created Opprtunitymonth = month ( opportunity[Closedate])

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.

May 2025 Monthly Update

Fabric Community Update - May 2025

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