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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

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
Community Champion
Community Champion

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
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

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.

Top Solution Authors
Top Kudoed Authors