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
mcornfield
Helper III
Helper III

DAX Formula IF Statement

I am trying to calculate Sum of Closed Accounts by Month.
I have a column of Dates for the last invoice date for all our customers.
I Created 2 Measures
9. Lastnonblank = CALCULATE(MAX(Dates[Date]),LASTNONBLANK(Dates[Date],[Invoice Count]))
Days from Last Invoice= FORMAT(Today()-[9. Lastnonblank],"#,##0")
Now I need to create a measure that IF Days from Last Invoice id greater then 90 then 1 otherwise 0
I keep getting an error for some reason
 
mcornfield_0-1638843942888.png

 

mcornfield_0-1638845876350.png

 

 

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @mcornfield 

 

First, you need to check the format of the "IF Test" field. Text cannot be compared with the value 90.

vzhangti_0-1639031208195.png

Correct results can be obtained by modifying the format of the "IF Test" field.

vzhangti_1-1639031241166.png

 

Best Regards,

Community Support Team _Charlotte

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

5 REPLIES 5
v-zhangti
Community Support
Community Support

Hi, @mcornfield 

 

First, you need to check the format of the "IF Test" field. Text cannot be compared with the value 90.

vzhangti_0-1639031208195.png

Correct results can be obtained by modifying the format of the "IF Test" field.

vzhangti_1-1639031241166.png

 

Best Regards,

Community Support Team _Charlotte

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

 

ebeery
Memorable Member
Memorable Member

@mcornfield how about showing us the IF statement you attempted to write, and the error you received?


Thanks for your reply i added a Screenshot to the post

@mcornfield if you would click the "See details" it would tell you exactly what the problem is:

ebeery_0-1638846320509.png

By using the "FORMAT" function in your [IF TEST] measure, you are converting that date difference into a Text data type.  But then in [IF TEST 2] you are comparing that against an integer value (90), which is not allowed.

One solution would be to change your [IF TEST] measure to:

 

IF TEST = VALUE(Today()-[9. Lastnonblank])

 



I am trying to calculate Sum of Closed Accounts by Month.
Days from Last Invoice= VALUE(Today()-[9. Lastnonblank])
Now I need to get a SUM by Month-Year
I keep getting TOTAL for some reason
mcornfield_0-1638880451680.png

 

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.