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
Anonymous
Not applicable

Finishing RETURN portion for calculating XIRR through multiple variable tables

First of all, I found this link quite helpful but did not resolve my issue as I am basically trying to achive something similar:
Solved: XIRR on a dynamic union table - Microsoft Fabric Community

Background:
I am trying to calculate the % difference of IRR based on a time slicer between the original cashflows (baseline) and added cashflows (change) depending on that time slicer.
Therefore, I`m defining tables within a measure to remain dynamic in what rows are selected.
1. Defining a table for baseline cashflow
2. calcualting the IRR  based on 1
3. Defining another table for the change cashflows
4. Union the 1 & 3
5. calculating the IRR based on 4
6. Stuck trying to return the following 


I have built the following measure: 

WAIRR Change = 

var tableWIRR3= SUMMARIZE(tableIRR3,[Asset Scenario ID],[Source Parameter],[IRR base],[total capex base],"WIRR base",[IRR base]*[total capex base])
var tableWIRR2= SUMMARIZE(tableIRR2,[Asset Scenario ID],[Source Parameter],[IRR],[total capex],"WIRR",[IRR]*[total capex])
Return 0 

I need to be returning
(  Sum([WIRR])/Sum([total capex])    -   (Sum([WIRR base])/Sum([total capex base]) )   -1

But cant seem to pull it off with the syntax and I need help checking what syntax to use and that my logic in building this is correct.

I`m also attaching the full code (as a picture, did not want to paste the entire thing in here) of the measure WAIRR Change below as I`m summarizing multiple tables to reach what I have written up.

Any help is much appreciated.


Full code of measureFull code of measure
4 REPLIES 4
lbendlin
Super User
Super User

Have you considered using the built-in XIRR function?

 

XIRR function (DAX) - DAX | Microsoft Learn

Anonymous
Not applicable

I am in fact using the XIRR function to calculate IRR for each of my "Asset scenario ID" under each "Source Parameter" at a previous step through this variable: 

var tableIRR3= SUMMARIZE(tablebase2,[Asset Scenario ID],[Source Parameter],"total capex base",SUMX(tablebase2,[Capex]),"IRR base",XIRR(tablebase2,[Cashflow],[Impacted Date]))

What I am trying to do is to calculate the weighted IRR (IRR * Capex) for two sub-sets of the data and visualise the change % between them and hence why 
"
I need to be returning
(  Sum([WIRR])/Sum([total capex])    -   (Sum([WIRR base])/Sum([total capex base]) )   -1
"
Comparing against tables created using the same exact syntax, I can see that the results are correct but I believe it`s SUMX that is re-evaluating and returning results that are not required. 

Please do take a look at the screenshot for the full measure, I would really appreciate help in closing this off. 

Many thanks for your comment.

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
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.

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

Anonymous
Not applicable

I have posted a reply but it didn`t go through it seems. 
Anyway, my code is:
"

WAIRR Change =

var tablebase2=
SUMMARIZE(CALCULATETABLE(
   'view view_stress_testing_result',KEEPFILTERS('view view_stress_testing_result'[Baseline/Change]="Baseline"),ALL('view view_stress_testing_result'[Source Fiscal Year])),
    'view view_stress_testing_result'[Asset Scenario ID],'view view_stress_testing_result'[Source Parameter],'view view_stress_testing_result'[Baseline/Change],'view view_stress_testing_result'[Impacted Date],
    "Cashflow",
    SUMX(FILTER(('view view_stress_testing_result'),'view view_stress_testing_result'[Impacted Parameter]="Cashflow"&&'view view_stress_testing_result'[Baseline/Change]="Baseline"),'view view_stress_testing_result'[Value]),
    "Capex",
    SUMX(FILTER(('view view_stress_testing_result'),'view view_stress_testing_result'[Impacted Parameter]="Capex"&&'view view_stress_testing_result'[Baseline/Change]="Baseline"),'view view_stress_testing_result'[Value])
)

var tableIRR3= SUMMARIZE(tablebase2,[Asset Scenario ID],[Source Parameter],"total capex base",SUMX(tablebase2,[Capex]),"IRR base",XIRR(tablebase2,[Cashflow],[Impacted Date]))
var tableWIRR3= SUMMARIZE(tableIRR3,[Asset Scenario ID],[Source Parameter],[IRR base],[total capex base],"WIRR base",[IRR base]*[total capex base])
var tableWAIRR3 = SUMMARIZE(tableWIRR3,[Source Parameter],"Sum WIRR",SUMX(tableWIRR3,[WIRR base]),"Sum Capex",SUMX(tableWIRR3,[total capex base]))
 
var IRRbase= SUMX(tableWAIRR3,[Sum WIRR])
return IRRBASE
"
 
Data:
Asset Scenario IDAsset ScenarioSource ParameterImpacted ParameterSource Fiscal YearImpacted Fiscal YearSource DateImpacted DateBaseline/ChangeStress DirectionValue
1Asset 1FX RatesCashflownull2020null01/01/2020Baselinenull-922165
1Asset 1FX RatesCashflownull2021null01/01/2021Baselinenull214134.3
1Asset 1FX RatesCashflownull2022null01/01/2022Baselinenull416461.4
1Asset 1FX RatesCashflownull2023null01/01/2023Baselinenull876725.6
1Asset 1FX RatesCashflownull2024null01/01/2024Baselinenull112972.2
1Asset 1FX RatesCashflownull2025null01/01/2025Baselinenull668644.6
1Asset 1FX RatesCashflownull2026null01/01/2026Baselinenull725756.2
2Asset 2FX RatesCashflownull2020null01/01/2020Baselinenull-520438
2Asset 2FX RatesCashflownull2021null01/01/2021Baselinenull314378.6
2Asset 2FX RatesCashflownull2022null01/01/2022Baselinenull223200.7
2Asset 2FX RatesCashflownull2023null01/01/2023Baselinenull141828.6
2Asset 2FX RatesCashflownull2024null01/01/2024Baselinenull659425.1
2Asset 2FX RatesCashflownull2025null01/01/2025Baselinenull119014.1
2Asset 2FX RatesCashflownull2026null01/01/2026Baselinenull878225.1


Expected results:

1956169


Shown results:

3787783

Which seems like XIRR is re-evaluating based on rows of [Source Parameter] only (where I need IRR to be calcualted for each Source parmater and asset ID underneath), and then for some reason multiplied by 2!

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.