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
roma
Advocate II
Advocate II

How to use if statement to test column values with measure

Hello Everyone,

 

I have a month column which has values Jan-Dec. I have 2 measure from which I get startmonth & endmonth from slicer

 

Now I have to write a measure to compare months values with selectedvalue of month. The condition is 

 

IF sum([Actual Cases]) > 0 then sum([Actual Cases])
elseif attr([Month]) < [startmonth] and attr(month([Formatted Month]))!=month([startmonth]) then 0
elseif (attr(month([Formatted Month]))=month([startmonth]) OR (attr([Month]) >= [startmonth])) and attr([Month]) <= attr([EndMonth]) then (sum([NetValues]) - [margin])/(12-[startmonth])+1)
elseif ((attr([Month]) >= [startmonth]) and attr([Month]) > attr([EndMonth])) then (sum([NetValues])/12)
end

 

Let me know how to write this measure in Power BI

3 REPLIES 3
v-diye-msft
Community Support
Community Support

Hi @roma 

 

Hi @roma 

 

Here're some similar threads could be your reference, but if you provide the dummy pbix that would be much helpful for us to provide the valuable advice:

https://community.powerbi.com/t5/DAX-Commands-and-Tips/IF-statement-with-multiple-columns-and-logica...

https://community.powerbi.com/t5/Desktop/IF-statement-as-measure/m-p/939608 

 

 

 

Community Support Team _ Dina Ye
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

The information you have provided is not making the problem clear to me. Can you please explain with an example. Can you share sample data and sample output.

Appreciate your Kudos.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@roma Read this post to get your answer quickly.

https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

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.