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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
lherna55
Frequent Visitor

RECREATE EXCEL FORMULA

I need to recreate an excel formula in power bi and make this a new column, but not with DAX, if I'm not mistaken I need to do it with the M language, but I don't know how to do it

THIS IS MY FORMULA IN EXCEL

=SI(TEXTO(N2;"mm/dd/aaaa")>="02/04/2024";SI.ERROR(SI(Y([@POTR]="xxxx");"REN";"ACT");"ACT");"ACT")

 

I tried to recreate the formula but I don't know why it gives an error, I suppose it's because of the date column, but I converted it to text and it still gives an error

lherna55_0-1708294355679.png

 

I would greatly appreciate if anyone can help me.

 

 

1 ACCEPTED SOLUTION
BA_Pete
Super User
Super User

Hi @lherna55 ,

 

There's a number of syntax issues with your M code.

Assuming that your [#"FECHA"] column is a Date data type, try something like this instead:

 

if [PORT.CARRIER DESC] = "SomeName" and [#"FECHA"] <= #date(2024, 01, 02) then "REN"
else "ACT"

 

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




View solution in original post

3 REPLIES 3
BA_Pete
Super User
Super User

Hi @lherna55 ,

 

There's a number of syntax issues with your M code.

Assuming that your [#"FECHA"] column is a Date data type, try something like this instead:

 

if [PORT.CARRIER DESC] = "SomeName" and [#"FECHA"] <= #date(2024, 01, 02) then "REN"
else "ACT"

 

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Thank you so much, the only think is that, you have to put the month in the center.

<=#date(2024,02,01).

 

I really appreciate your help¡¡¡

 

 

lbendlin
Super User
Super User

While you can create calculated columns with DAX it is indeed recommended to instead implement these in Power Query whenever possible.

 

Can you formulate the business requirement behind your Excel formula?  Converting from Excel to Power BI is often an exercise in futility (although Greg Deckler has a thread here that lists all the equivalents)

 

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).

Do not include sensitive information or anything not related to the issue or question.

If you are unsure how to upload data please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...

Please show the expected outcome based on the sample data you provided.

Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.