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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
rawandshoraa
Frequent Visitor

if statement

Greetings,

i want to use if statement in power bi, but i way i'm using it, doesn't achieve the derired. 

 

i want to count the number of new orders for today. if blank return "No New Orders", if true return count(ord_num)

 

i tried to create a new column: 

no_ords = if(LEN(ords[ORD_NUM]) = 0 , 'No New Orders", count(ords[ORD_NUM]))
it returns the following error: The following syntax error occurred during parsing: Invalid token, Line 1, Offset 49, 'No Orders", count(ords[ORD_NUM])))).
 
 
Any Suggetions?? 
 
Regards 
1 ACCEPTED SOLUTION
tackytechtom
Most Valuable Professional
Most Valuable Professional

hI @rawandshoraa ,

 

Did you try to create a calculated column? My syntax works for measures only 🙂 

 

/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

View solution in original post

4 REPLIES 4
tackytechtom
Most Valuable Professional
Most Valuable Professional

hI @rawandshoraa ,

 

Did you try to create a calculated column? My syntax works for measures only 🙂 

 

/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

Thank you 🙂

tackytechtom
Most Valuable Professional
Most Valuable Professional

Hi @rawandshoraa ,

 

I would probably write something like this. Note, I assumed you have a Date dimension called 'DATES'

no_ords =
VAR _OrdersToday =
CALCULATE ( 
    COUNT ( ords[ORD_NUM] ),
    DATES[Date] = TODAY()
)
RETURN
IF ( _OrdersToday > 0, _OrdersToday, "No New Orders" ) 

 

Let me know if this helps!

/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

Greetings

appritiate your help, 

i tried your solution, it gives the following:

Expressions that yield variant data-type cannot be used to define calculated columns.

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

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.