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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Syndicate_Admin
Administrator
Administrator

Convert Excel Formula using INDEX

I'm a Power BI newbie.

I have an excel sheet (ODBC) that I want to convert to Power BI, I already created the table but I have a formula in Excel that I don't know how to convert to Power BI, I use the INDEX and MATCH functions, but when I try to do the same in my table as a new column I don't get the INDEX function.

The formula I have looks for the first occurrence of month and year in DateColumn that has CURRENCY = PES and then retrieves the value of ExchangeTypeColumn to multiply it by AMOUNT, to get the BALANCE column

Here's the Excel formula:

IF(CURRENCY= "PES", AMOUNT, AMOUNT*INDEX(ColumnRateExchange,MATCH(1,(EXTRACT(DATE,5,2)=EXTRACT(ColumnDates,5,2))*(LEFT(DATE,4)=LEFT(ColumnDates,4))*(ColumnCurrency="PES"),0)))

And example data:

A.

NameDateCoinAmountT.C.Balance

3001

Prov120231231USD11050.41190373.15
3001Prov120231231USD31162.611536860.59
3005Prov220231206PES904817.227715959048
3005Prov220231231PES4411816.8935184644118

How do I create the formula in a calculated column in Power Bi? I'm using Direct Query to get the data.

Thank you

2 REPLIES 2
TheoC
Super User
Super User

Hi @Syndicate_Admin 

 

To do it, you will need to take a few steps:

 

1. Calculated Column for Year:

 

Year = YEAR ( [Date] )

 

2. Calculated Column for Month:


Month = MONTH ( [Date] )

 

3. Calculated Column for FX Rate:

 

ExchangeRate =

 

VAR TargetYear = [Year]
VAR TargetMonth = [Month]

 

RETURN

 

CALCULATE (
     FIRSTNONBLANK ( Table[ExchangeTypeColumn] , 0 ) ,
          FILTER ( Table, YEAR ( Table[Date] ) = TargetYear &&
          MONTH ( Table[Date] ) = TargetMonth &&
          Table[CURRENCY] = "PES" ) , REMOVEFILTERS ( 'Table' )

)

 

4. Calculated Column for the Balance:

 

Balance = IF ( [CURRENCY] = "PES" , [AMOUNT] , [AMOUNT] * [ExchangeRate] )

 

Please adjust / adapt and hopefully it helps or at least guides you through the process.

 

All the best.

 

Theo

 

If I have posted a response that resolves your question, please accept it as a solution to formally close the post.

Also, if you are as passionate about Power BI, DAX and data as I am, please feel free to reach out if you have any questions, queries, or if you simply want to connect and talk to another data geek!

Want to connect?www.linkedin.com/in/theoconias

Thanks for the reply, I assume that what was translated as CALCULATE is equivalent to the "CALCULATE" function, but I don't know what function can be RETURN.

How to put the function in English without having to translate it?

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.