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
MMG_F1RST
New Member

Powequery Formula using If inside other ifs

Hi,

I have a foruma in excel that im converting into Powerbi (Powerquery) but im having trouble to recreaty if inside other ifs.

IF($AS6<DATE(YEAR(AZ$5);MONTH(AZ$5);1);
 IF($AU6="";NETWORKDAYS(DATE(YEAR(AZ$5);MONTH(AZ$5);1);DATE(YEAR(AZ$5);MONTH(AZ$5)+1;1)-1;Feriado[Nome])*8;
 IF($AU6<DATE(YEAR(AZ$5);MONTH(AZ$5);1);"0";   IF($AU6>=DATE(YEAR(AZ$5);MONTH(AZ$5)+1;1)-1;NETWORKDAYS(DATE(YEAR(AZ$5);MONTH(AZ$5);1);DATE(YEAR(AZ$5);MONTH(AZ$5)+1;1)-1;Feriado[Nome])*8;NETWORKDAYS(DATE(YEAR(AZ$5);MONTH(AZ$5);1);$AU6;Feriado[Nome])*8)));........)

Is there a way to recreate this kind of excel forumla in Powerquery mode inside Powerbi?

Thx

1 REPLY 1
edhans
Super User
Super User

Yes, and it is easier. In Excel it is IF(Condition, True, False) and you nest other statemetns in the FALSE section.

 

In Power Query it is always 3 statements, it is either:
if then else if
or
if then else

if [some field] = 1 then "It works"
else if [Some field] = 2 then "It doesn't work" 
else if [some field] = null then "It is empty"
else null


You must have that final else. It isn't like Excel where if you omit the FALSE condition it still works. It will throw an error in Power Query.

And it is case sensitive. if/then/else, not If/Then/Else, or IF/THEN/ELSE. Those will throw errors.

The issue is you cannot reference cells in Power Query, so there is no AS6 or AZ4. 

You need to share data with us and explain what you are trying to do. It may be PQ isn't the right place for it, could be a DAX measure. Could be a combination. 

Never approach a Power BI project with "how do I translate this long Excel formula into Power BI?" It is always "How can I create this output in Power BI with this data?"

How to get good help fast. Help us help you.

How To Ask A Technical Question If you Really Want An Answer

How to Get Your Question Answered Quickly - Give us a good and concise explanation
How to provide sample data in the Power BI Forum - Provide data in a table format per the link, or share an Excel/CSV file via OneDrive, Dropbox, etc.. Provide expected output using a screenshot of Excel or other image. Do not provide a screenshot of the source data. I cannot paste an image into Power BI tables.



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

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.