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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
ashwinkolte
Helper I
Helper I

XIRR help needed

As we know below is the function for XIRR in power BI:
= XIRR(<tablename>, [Cashflow], [Date])

 

Consider the below table

Name of asset Col 1 (Invested amount)Col 2 (Withdrawal amount)Col 3 (Invested date)Col 4 (Withdrawal date)
Asset 1-1000001230001 Jan 202031 Dec 2022


How do I use the XIRR formula in Power BI for the above table given that we have 2 columns for Cashflow and 2 columns for date in the same row. Please note - I don’t want to unpivot the columns and align the amount and dates columns vertically.
So, the question is - how to use multiple columns for cashflow and multiple columns for dates in the Power BI XIRR formula, something equivalent to what can be easily done in excel e.g. =XIRR (Col1:Col2, Col3:Col4)

1 ACCEPTED SOLUTION
v-stephen-msft
Community Support
Community Support

Hi @ashwinkolte ,

 

Without unpivotting columns, it's difficult.

But if you just don't want to unpivot columns in Power Query, how about unpivotting in Power BI Desktop using DAX?

Please kindly refer to

DAX Unpivot - Microsoft Power BI Community

And below are the measure and the result:

Measure = var _table=

    UNION(
        SELECTCOLUMNS('Table',"Name",[Name of asset],"Cashflow",[Col 1 (Invested amount)],"Date",[Col 3 (Invested date)]),
        SELECTCOLUMNS('Table',"Name",[Name of asset],"Cashflow",[Col 2 (Withdrawal amount)],"Date",[Col 4 (Withdrawal date)])
   
    )


    return XIRR(_table,[Cashflow],[Date])

vstephenmsft_0-1679642689058.png

 

                                                                                                                                                         

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.           

View solution in original post

2 REPLIES 2
v-stephen-msft
Community Support
Community Support

Hi @ashwinkolte ,

 

Without unpivotting columns, it's difficult.

But if you just don't want to unpivot columns in Power Query, how about unpivotting in Power BI Desktop using DAX?

Please kindly refer to

DAX Unpivot - Microsoft Power BI Community

And below are the measure and the result:

Measure = var _table=

    UNION(
        SELECTCOLUMNS('Table',"Name",[Name of asset],"Cashflow",[Col 1 (Invested amount)],"Date",[Col 3 (Invested date)]),
        SELECTCOLUMNS('Table',"Name",[Name of asset],"Cashflow",[Col 2 (Withdrawal amount)],"Date",[Col 4 (Withdrawal date)])
   
    )


    return XIRR(_table,[Cashflow],[Date])

vstephenmsft_0-1679642689058.png

 

                                                                                                                                                         

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.           

Dear @v-stephen-msft

Thanks for the solution . Glad to know how to unpivot columns using DAX . Thanks a lot. It works !

However still I am curious if there is a definitve answer to how to achieve this without unpivoting,  something which is so easily possible in excel. 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors