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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
rk_nithi
Regular Visitor

XIRR calculation using DAX

Hello,

 

i need your support to calculate XIRR values of my mutual fund investment. I have a table as below

Date  Transaction AmountTransaction TypeInvestment Category
05-12-2019-10000BuyDebt
08-12-2019-90000BuyDebt
23-12-201950000SellDebt
14-01-202040000SellDebt
25-02-2020-10000BuyEquity
02-03-2020-50000BuyDebt
03-03-2020-5000BuyEquity
09-03-2020-2500BuyEquity
13-03-2020-2500BuyEquity
24-03-2020-2500BuyEquity
03-04-2020-2500BuyEquity
15-04-2020-11500BuyDebt
16-04-2020-6500BuyEquity
14-06-2020-232000BuyDebt
05-08-2020306027.52SellDebt
10-08-2020-99995BuyDebt
31-08-2020100142.49SellDebt
10-09-2020-99995BuyDebt
21-09-202025000SellDebt
11-01-202125000SellDebt
26-01-202150859.19SellDebt
03-02-20216.88SellDebt
02-03-2021-9999.5BuyEquity
31-03-2021-9999.5BuyEquity
05-04-2021-49997.5BuyEquity
07-04-2021-9999.5BuyEquity
12-04-2021-7999.6BuyEquity
28-04-2021-9999.5BuyEquity
07-05-2021-9999.5BuyEquity
28-05-2021-9999.5BuyEquity
08-06-2021-9999.5BuyEquity
28-06-2021-9999.5BuyEquity
07-07-2021-9999.5BuyEquity
27-07-2021-9999.5BuyEquity
09-08-2021-9999.5BuyEquity
16-11-202159160.07SellEquity
22-11-2021-24998.75BuyEquity
17-12-2021-9999.5BuyEquity
20-12-2021-9999.5BuyEquity
27-01-2022-4999.75BuyEquity
01-02-2022-9999.5BuyDebt
07-02-2022-4999.75BuyEquity
10-02-2022-4999.75BuyEquity
15-02-2022-24998.75BuyDebt
16-02-2022-4999.75BuyEquity
18-02-2022-24998.75BuyEquity
28-02-2022-4999.75BuyEquity
01-03-2022-9999.5BuyDebt
10-03-2022-4999.75BuyEquity

 

my question is how to calculate XIRR of my investments in the above format? also the current market value is not in the transaction table mentioend above and it is in different table. how to bring these tables together and calculate the XIRR value?

 

Thanks

1 ACCEPTED SOLUTION

Hii @rk_nithi 

Here the link of my pbix file :

https://netorgft12209796-my.sharepoint.com/:u:/g/personal/rohit91_oxygenbi_com/EVnRPLWGNnVAuYMdprYfV... 


Did it work? ✔ Give a Kudo • Mark as Solution – help others too!

View solution in original post

10 REPLIES 10
Ohouot225
Frequent Visitor

This is my proposition:

Create a single table in Power Query.

1. Transform the actual value to get a Table like that:

 

DateTransaction Type

Cashflow

20/11/2025Overall Portfolio95.000

 

  •      Add a custom column with this script 
DateTime.LocalNow()​
  • Name the column Date and move at the first column.
  • Change the name 'Portfolio' to 'Transaction Type' and 'Current Value' to 'Cashflow', and ensure that the column order follows the same sequence as in the transaction table.

 

For the transaction Table, you will have something like this:

 

Ohouot225_0-1763985727214.png

 

  •   Begin by adding a conditional column for the Cashflow
  •   The Append in Power Query to add the Actual value to the Transaction Table (Check the order of the columns before)

 

Now you can easily use the XIIR function with both table

XIRR_Investment = 
XIRR(Transactions, Transactions[Cashflow], Transactions[Date])

Ohouot225_1-1763986202311.png

 

 

NB: The data I use may differ from yours.

 

Hi @rk_nithi ,

Thanks for reaching out to the Microsoft fabric community forum. 

 

I would also take a moment to thank @Ohouot225   , for actively participating in the community forum and for the solutions you’ve been sharing in the community forum. Your contributions make a real difference.

I hope the above details help you fix the issue. If you still have any questions or need more help, feel free to reach out. We’re always here to support you 

 

Best Regards, 
Community Support Team 

Ohouot225
Frequent Visitor

  • Split the columns:

             Make sure that the
Transaction Amount

      and

Date

    are in separate columns. If this hasn’t been done yet, you’ll need to separate them properly in Power Query.
  1. Align the column structure: Ensure that both tables (transactions and current market value) have the same columns, in the same order, with consistent names.
  2. Append the tables: Use the Append Queries option in Power Query to merge the two tables into a single table containing all cash flows.
  3. Calculate the XIRR: Once the unified table is ready, you can apply the DAX function XIRR() to compute the extended internal rate of return based on the Cash Flow and Date columns.

 

 

rohit1991
Super User
Super User

Hii @rk_nithi 

 

Below are the exact items you must create:

  1. Create a Cashflow Column :
Cashflow =
IF(
    'Transactions'[Transaction Type] = "Buy",
    - 'Transactions'[Transaction Amount],
    'Transactions'[Transaction Amount]
)

 

  1.  Create a Measure for Current Market Value
CurrentValue_CF :=
MAX('CurrentValue'[Current Value])

 

  1. Final_CF Column
Final_CF = 'Transactions'[Cashflow]

 

  1. Create the XIRR Measure
XIRR_Investment :=
VAR CF =
    UNION(
        SELECTCOLUMNS(
            ALL('Transactions'),
            "Amount", 'Transactions'[Cashflow],
            "Date", 'Transactions'[Date]
        ),
        ROW(
            "Amount", [CurrentValue_CF],
            "Date", TODAY()
        )
    )
RETURN
IF(
    HASONEVALUE('Transactions'[Date]),
    BLANK(),       
    XIRR(CF, [Amount], [Date]) 
)

 

image.png

 


Did it work? ✔ Give a Kudo • Mark as Solution – help others too!

Hi Rohit1991,

 

can you please share the pbix file for better understanding?

Hii @rk_nithi 

Here the link of my pbix file :

https://netorgft12209796-my.sharepoint.com/:u:/g/personal/rohit91_oxygenbi_com/EVnRPLWGNnVAuYMdprYfV... 


Did it work? ✔ Give a Kudo • Mark as Solution – help others too!

This is my proposition:

Create a single table in Power Query.

1. Transform the actual value to get a Table like that:

 

DateTransaction Type

Cashflow

20/11/2025Overall Portfolio95.000

 

  •      Add a custom column with this script 
DateTime.LocalNow()​
  • Name the column Date and move at the first column.
  • Change the name 'Portfolio' to 'Transaction Type' and 'Current Value' to 'Cashflow', and ensure that the column order follows the same sequence as in the transaction table.

 

For the transaction Table, you will have something like this:

 

Ohouot225_0-1763985727214.png

 

  •   Begin by adding a conditional column for the Cashflow
  •   The Append in Power Query to add the Actual value to the Transaction Table (Check the order of the columns before)

 

Now you can easily use the XIIR function with both table

XIRR_Investment = 
XIRR(Transactions, Transactions[Cashflow], Transactions[Date])

Ohouot225_1-1763986202311.png

 

 

NB: The data I use may differ from yours.

 

Hans-Georg_Puls
Super User
Super User

Hi @rk_nithi ,

according to the definition of the XIRR function (XIRR( CashFlows, [Payment], [Date] )) I would try:

XIRR(Your Table Name, [Transaction Amount], [Date])

Did you already try that?

What do you want to do with the "current market value"?

Hi DNMAF,
Thanks for the reply, in my table only transactions of bought and sold details are available and you know the value of previous investments would change as per per market value. So the current value of total investments would be different than the invested amount. to calculate overall return on investment , i think we should calculate difference between current market value and invested value right? my question is in the XIRR formula there is no possibility to consider current market value, how to accommodate that?

Hi @rk_nithi ,

 

to include the current market value you could do the following (assuming that the current market values are positive and the table with the market values has a date column):

 

  1. Create a table with all relevant values using UNION: (your column and table names might be different)
    All Values = UNION(SELECTCOLUMNS('Market Value', "Date", [Date], "Value", [Market Value]), SELECTCOLUMNS('Transaction', "Date", [Date], "Value", [Transaction Amount]))
  2. Define an appropriate measure like the following:
    XIRR with market values =
    VAR MinDate = CALCULATE(MIN('All Values'[Date]), REMOVEFILTERS('All Values'))
    VAR MaxDate = SELECTEDVALUE('All Values'[Date], MAX('All Values'[Date]))
    RETURN
        CALCULATE(
            XIRR( 'All Values', [Value], [Date],, BLANK()),
            REMOVEFILTERS('All Values'),
            'All Values'[Date] >= MinDate && 'All Values'[Date] <= MaxDate
        )

Does that fulfil your requirements?

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

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

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.