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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

SUMX not returning right results (from variable tables in a measure)

Hi all, 
My issue is: 
1. Created a measure that identifies var tables 
2. I`m trying to return the right results from my table but using SUMX, the measure keeps re-evaluating and gives wrong results

Here is my measure:

"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 result= SUMX(tableIRR3,[total capex base])
Return result"

I`m comparing by using the same syntax to create tables  and I can see the results being returned correctly at each step. 
(So creating a table called tablebase2, tableIRR3 and checking the results there) and also through the original data and pivot tables on Excel. 

The SUMX seems to be re-evaluating when used in the "var result" based on my visual which contains only "Source Parameter"

Please see data below:

tablebase2 = 
"Asset Scenario ID" "Source Parameter" "Baseline/Change" "Impacted Date" "Cashflow" "Capex"
1FX RatesBaseline01/01/2020 00:00:00-922164.6663 
2FX RatesBaseline01/01/2020 00:00:00-520437.5707 
2FX RatesBaseline01/01/2021 00:00:00314378.5714 
1FX RatesBaseline01/01/2021 00:00:00214134.2835 
1FX RatesBaseline01/01/2022 00:00:00416461.43303774.1754
2FX RatesBaseline01/01/2022 00:00:00223200.713255614.3985
1FX RatesBaseline01/01/2023 00:00:00876725.5828159712.9184
2FX RatesBaseline01/01/2023 00:00:00141828.5901102293.8374
2FX RatesBaseline01/01/2024 00:00:00659425.0787894341.0978
1FX RatesBaseline01/01/2024 00:00:00112972.2262989518.2397
1FX RatesBaseline01/01/2025 00:00:00668644.6012381667.8337
2FX RatesBaseline01/01/2025 00:00:00119014.0851229504.8804
1FX RatesBaseline01/01/2026 00:00:00725756.1797364477.9102
2FX RatesBaseline01/01/2026 00:00:00878225.1378438402.0113

TableIRR3=
"Asset Scenario ID" "Source Parameter" "total capex base" "IRR base"
2FX Rates1920156.22540.553920970857143
1FX Rates2199151.07740.405862980335951

Expected return result = sum of the "total capex base" column = 4,119,307
Actual returned result is 2 times that at = 8,238,615
Leading me to believe what is going on is that the measure is calculating the sum for FX Rates and holding it in 2 rows (hence why the result is duplicated in value).

Also note, my full measure is way bigger and I`m attaching it as a screenshot


Capture.PNG
3 REPLIES 3
Anonymous
Not applicable

Hi @Anonymous,

Can you please share a pbix or some dummy data that keep the raw data structure with expected results? It should help us clarify your scenario and test to coding formula.

How to Get Your Question Answered Quickly  

Regards,

Xiaoxin Sheng

Anonymous
Not applicable

"

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 tableIRR3SUMMARIZE(tablebase2,[Asset Scenario ID],[Source Parameter],"total capex base",SUMX(tablebase2,[Capex]),"IRR base",XIRR(tablebase2,[Cashflow],[Impacted Date]))
var tableWIRR3SUMMARIZE(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 IRRbaseSUMX(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


Visual: bar chart with y-axis=Source Parameter and x-axis=WAIRR Change.

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!

I`ll try and upload the PBIX now so that full data would be available too.

Anonymous
Not applicable

I guess in summary, what I`m trying to do is to return the sum of the values already calculated in either:
table  tableWIRR3   column "WIRR Base" OR
table tableWAIRR3  column "Sum WIRR"
Without trigerring PowerBI to recalculate the XIRR function in table tableIRR3. 

The XIRR is reevaluating as if all rows of the data were for the same asset (perhaps because I`m visualising only Source Parameter? but that is what I need)

I`m unable to upload a PBIX unfortunatly due to company policy.

 

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.