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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
Priya_K
Regular Visitor

How to write between function in power bi

I am new to Power BI. I am trying to create a calculated field using between or if functions.

 

If the number in Column A is between 17 & 25 I want the result to be displayed as Critical & Improve

 

I am getting an error if I use between function . When I use if function with and in it, it is giving me an error. 

What am I doing wrong?

Thank you. 

 

1 ACCEPTED SOLUTION
edhans
Community Champion
Community Champion


@Priya_K wrote:

It worked when I use "&" instead of "and" in my formula in power query.

IF(
('Work Items - All history by month'[Inherent Risk Score]>17) &&
('Work Items - All history by month'[Inherent Risk Score]<25),
"critical",


That is DAX. DAX uses a function similar to Excel - IF(condition, true, false) and as I noted above, you should use &&.

 

Power Query uses this - and it is case sensitive.

if condition then true else false

And if you have multiple conditions, then it is

if condition and condition and condition then true else false


Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

6 REPLIES 6
edhans
Community Champion
Community Champion

If you are writing it as a calculated column in DAX, you want to use 

=IF(
Table2[Tickets]>2 && Table2[Tickets]<4
,1
,0
)

You could use an AND() funciton in there, but AND() only allows two conditions, whereas you can use && until the cows come home. 

 

If you are doing it in Power Query before it gets to DAX, (which I recommend for performance reasons), add a custom column then use:

if [Tickets] > 2 and [Tickets] < 5 then 1 else 0

Power Query can have multiple and statements. And or statements. And levels with parenthesis. Much more powerful.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

Thank you.

Yes, I prefer Power Query. I am getting an error when I use and function in there.  

edhans
Community Champion
Community Champion

Can you share that error, and maybe a screen shot of it? 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

It worked when I use "&" instead of "and" in my formula in power query.

IF(
('Work Items - All history by month'[Inherent Risk Score]>17) &&
('Work Items - All history by month'[Inherent Risk Score]<25),
"critical",

edhans
Community Champion
Community Champion


@Priya_K wrote:

It worked when I use "&" instead of "and" in my formula in power query.

IF(
('Work Items - All history by month'[Inherent Risk Score]>17) &&
('Work Items - All history by month'[Inherent Risk Score]<25),
"critical",


That is DAX. DAX uses a function similar to Excel - IF(condition, true, false) and as I noted above, you should use &&.

 

Power Query uses this - and it is case sensitive.

if condition then true else false

And if you have multiple conditions, then it is

if condition and condition and condition then true else false


Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

Thank you very much. 

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.