Adding Rows to get a Total

Please assist. I am trying to get the total value for Tax paid which is made up of

Tax paid
Tax refunded
Fiscal unity tax transfers
Tax cash flow adjustments
These columns has got values, accept for Tax cash flow adjustment which is correct:

I am using DAX:

CombinedAmount =
VAR SelectedCashFlowDescription = SELECTEDVALUE(‘CashflowDiscriptions’[description], “None”)
RETURN
IF(
SelectedCashFlowDescription = “Interco capital returned”,
678,
CALCULATE(
SUM(‘ZTBR’[Amount in USD]),
‘ZTBR’[Roll_Up_Function] IN {
“Cash flow from ops - management”,
“Cash flow from trading”,
“Profit before Brambles allocations Total”,
“Depreciation and amortisation”,
“IPEP expense”,
“Disposals & impairment of fixed assets”,
“Profit on disposal of pooling equipment”,
“Scrapped pooling equipment”,
“Impairment or valuation adjustment of pooling equipment”,
“Disposals or valuation adjustments of other fixed assets”,
“Other cash flow from trading adjustments”,
“Share-based payments expense”,
“Working capital mvts excl. provisions”,
“Debtor movements”,
“Creditor movements”,
“Inventory movements”,
“Prepayment movements”,
“Provision movements”,
“Change in capex creditors”,
“Brambles allocations not in mgt cash flow”,
“Interco interest and guarantee fees”,
“Interco cash flows”,
“Interco royalties”,
“Statutory reallocations”,
“Internal restructuring”,
“Interco dividends Total”,
“Change in interco balances”,
“Change in interco recharge clearing”,
“FX on interco debt”,
“Interco capital returned”,
“Interco cash flow adjustments”,
“Interest expense Total”,
“Interest revenue”,
“Interest received”,
“Lease interest”
}
) + CALCULATE(
SUM(Bracs[Metric Value ($)]),
Bracs[Metric] IN {
“Pension plan adjustment”,
“Working capital - budget flex”,
“Pooling equipment additions”,
“Pooling equipment replacements”,
“Pooling equipment internal transfers”,
“Other PP&E additions”,
“Other PP&E replacements”,
“Other PP&E internal transfers”,
“Joint venture loans”,
“WDV pooling equip. disposals & write-offs”,
“Gain pooling equip. disposals & write-offs”,
“WDV other PP&E disposals”,
“Profit other PP&E disposals”,
“Discount unwind on long term provisions”,
“Tax paid”,
“Tax refunded”,
“Fiscal unity tax transfers”,
“Other cash flow items”,
“FX adjustments to cash flow”,
“Change in cash net of overdraft”
}
)
)
To get values above. The DAX i tried to get Net tax paid gives no output:

NetTaxPaidTest =
CALCULATE(
SUM(Bracs[Metric Value ($)]),
Bracs[Metric] IN {
“Tax paid”,
“Tax refunded”,
“Fiscal unity tax transfers”,
“Tax cash flow adjustments”
}
)

image

Hi @Yrstruly ,
Could you clear out - to which measure you need help - NextTaxPaidTest or ?
It’s Tax paid +Tax refunded+Fiscal unity tax transfers+Tax cash flow adjustments ?

Could you also provide pbix file - usually it helps to find solution ?

Thank you.

Please find the sample pbix attached. You can use any of these rows an mimic what I am trying to achieve.

Sample 2.pbix (121.2 KB)

Hi @Yrstruly ,

Thank you for your sample pbix.

I find several problems within your Amount column ( Letters, spaces) → so I extract data, clean a little bit so I can change to Decimal number before we can go further.

There are different solutions (as it is usually with DAX) but one solution you can find at

Sample_Yrstruly.pbix (24.4 KB)

I pick random 3 Cashflow basis but hope that is what are you looking for.

If not could you provide more inputs and details what to expect ?
Thanks.

@mspanic
Here is the PBIX, https://drive.google.com/file/d/1nSBwCKqxdEYe-pmK9UX2nPDV7XOpinfO/view?usp=sharing

Table CashFlowDescriptions[Descriptions] include the row Net Tax Paid, also the rows that made up this amount. Te Bracs table contains the values. I cant seem to get this row to display the total of the three rows that it is made up of.

@Yrstruly
if I got it - you would like to display Net Tax paid in separate row

for total I left BLANK () but you can change it for what you need

I use your NetTaxPaidTest formula
and use it within NewDisplay_amount measure - change the context for ALL description and use it back so you can use it within the table with others

NewDisplay_Amount = 
VAR _TotalNetTaxPaid =CALCULATE([NetTaxPaidTest], ALL(CashflowDiscriptions[description]))
VAR _Result =
SWITCH(TRUE(), 
 SELECTEDVALUE(CashflowDiscriptions[description])="Net tax paid", _TotalNetTaxPaid, 
 HASONEVALUE(CashflowDiscriptions[description]),  [NetTaxPaidTest],
 BLANK())

RETURN _Result

This HASONEVALUE I use it to divide table row and total.

If you need anything else please let us know.

@mspanic
I cant find the calculation you created and it should be incorporated into this dax,

CombinedAmount =
VAR SelectedCashFlowDescription = SELECTEDVALUE(‘CashflowDiscriptions’[description], “None”)
RETURN
IF(
SelectedCashFlowDescription = “Interco capital returned”,
678,
CALCULATE(
SUM(‘ZTBR’[Amount in USD]),
‘ZTBR’[Roll_Up_Function] IN {
“Cash flow from ops - management”,
“Cash flow from trading”,
“Profit before Brambles allocations Total”,
“Depreciation and amortisation”,
“IPEP expense”,
“Disposals & impairment of fixed assets”,
“Profit on disposal of pooling equipment”,
“Scrapped pooling equipment”,
“Impairment or valuation adjustment of pooling equipment”,
“Disposals or valuation adjustments of other fixed assets”,
“Other cash flow from trading adjustments”,
“Share-based payments expense”,
“Working capital mvts excl. provisions”,
“Debtor movements”,
“Creditor movements”,
“Inventory movements”,
“Prepayment movements”,
“Provision movements”,
“Change in capex creditors”,
“Brambles allocations not in mgt cash flow”,
“Interco interest and guarantee fees”,
“Interco cash flows”,
“Interco royalties”,
“Statutory reallocations”,
“Internal restructuring”,
“Interco dividends Total”,
“Change in interco balances”,
“Change in interco recharge clearing”,
“FX on interco debt”,
“Interco capital returned”,
“Interco cash flow adjustments”,
“Interest expense Total”,
“Interest revenue”,
“Interest received”,
“Lease interest”
}
) + CALCULATE(
SUM(Bracs[Metric Value ($)]),
Bracs[Metric] IN {
“Pension plan adjustment”,
“Working capital - budget flex”,
“Pooling equipment additions”,
“Pooling equipment replacements”,
“Pooling equipment internal transfers”,
“Other PP&E additions”,
“Other PP&E replacements”,
“Other PP&E internal transfers”,
“Joint venture loans”,
“WDV pooling equip. disposals & write-offs”,
“Gain pooling equip. disposals & write-offs”,
“WDV other PP&E disposals”,
“Profit other PP&E disposals”,
“Discount unwind on long term provisions”,
“Tax paid”,
“Tax refunded”,
“Fiscal unity tax transfers”,
“Other cash flow items”,
“FX adjustments to cash flow”,
“Change in cash net of overdraft”
}
)
)

Blockquote

@Yrstruly ,

So to display also CombinedAmount for Net Tax paid you need to

a) create NetTaxPaidTest measure as you describe it in your first post (or incorporate this in new step but it is cleaner to have measure branching)

NetTaxPaidTest =
CALCULATE(
SUM(Bracs[Metric Value ($)]),
Bracs[Metric] IN {
“Tax paid”,
“Tax refunded”,
“Fiscal unity tax transfers”,
“Tax cash flow adjustments”
}
)

b) adapt CombinedAmount to incorporate Net Tax paid

New CombinedAmount = 
VAR SelectedCashFlowDescription = SELECTEDVALUE('CashflowDiscriptions'[description], "None")
VAR _TotalNetTaxPaid =CALCULATE([NetTaxPaidTest], ALL(CashflowDiscriptions[description]))
RETURN
    SWITCH(TRUE(),
        SelectedCashFlowDescription = "Interco capital returned", 678,
        SelectedCashFlowDescription = "Net tax paid", _TotalNetTaxPaid, 
        CALCULATE(
            SUM('ZTBR'[Amount in USD]),
            'ZTBR'[Roll_Up_Function] IN {
                "Cash flow from ops - management",
                "Cash flow from trading",
                "Profit before Brambles allocations Total",
                "Depreciation and amortisation",
                "IPEP expense",
                "Disposals & impairment of fixed assets",
                "Profit on disposal of pooling equipment",
                "Scrapped pooling equipment",
                "Impairment or valuation adjustment of pooling equipment",
                "Disposals or valuation adjustments of other fixed assets",
                "Other cash flow from trading adjustments",
                "Share-based payments expense",
                "Working capital mvts excl. provisions",
                "Debtor movements",
                "Creditor movements",
                "Inventory movements",
                "Prepayment movements",
                "Provision movements",
                "Change in capex creditors",
                "Brambles allocations not in mgt cash flow",
                "Interco interest and guarantee fees",
                "Interco cash flows",
                "Interco royalties",
                "Statutory reallocations",
                "Internal restructuring",
                "Interco dividends Total",
                "Change in interco balances",
                "Change in interco recharge clearing",
                "FX on interco debt",
                "Interco capital returned",
                "Interco cash flow adjustments",
                "Interest expense Total",
                "Interest revenue",
                "Interest received",
                "Lease interest"
            }
        ) + CALCULATE(
            SUM(Bracs[Metric Value ($)]),
            Bracs[Metric] IN {
                "Pension plan adjustment",
                "Working capital - budget flex",
                "Pooling equipment additions",
                "Pooling equipment replacements",
                "Pooling equipment internal transfers",
                "Other PP&E additions",
                "Other PP&E replacements",
                "Other PP&E internal transfers",
                "Joint venture loans",
                "WDV pooling equip. disposals & write-offs",
                "Gain pooling equip. disposals & write-offs",
                "WDV other PP&E disposals",
                "Profit other PP&E disposals",
                "Discount unwind on long term provisions",
                "Tax paid",
                "Tax refunded",
                "Fiscal unity tax transfers",
                "Other cash flow items",
                "FX adjustments to cash flow",
				"Change in cash net of overdraft"
            }
        )
    )

use switch true instead of multiple if then else statement

Hope this is what are you looking for

@mspanic

Please share the PBIX where you apply this dax, i still dont see the row Net tax paid in the code you provided?

Net tax paid should display as a row, it does not

@Yrstruly, did you place @mspanic’s New CombinedAmount measure in a table with description? I did (using your second sample data in “PL101 (4).pbit”) and indeed I see a row for “Net Tax Paid”.

1 Like

I see Net Tax Paid. I should be able to select account code and view the row showing me the account code also. When i do select account code, Net Tax Paid dissapear.
image

@Yrstruly - to do so change
New Combined Amount so it’s calculate Next Paid Tax for all CashflowDiscriptions (not just description)

so new combinedAmount should be:

New CombinedAmount = 
VAR SelectedCashFlowDescription = SELECTEDVALUE('CashflowDiscriptions'[description], "None")
VAR _TotalNetTaxPaid =CALCULATE([NetTaxPaidTest], ALL(CashflowDiscriptions))
RETURN
    SWITCH(TRUE(),
        SelectedCashFlowDescription = "Interco capital returned", 678,
        SelectedCashFlowDescription = "Net tax paid", _TotalNetTaxPaid, 
        CALCULATE(
            SUM('ZTBR'[Amount in USD]),
            'ZTBR'[Roll_Up_Function] IN {
                "Cash flow from ops - management",
                "Cash flow from trading",
                "Profit before Brambles allocations Total",
                "Depreciation and amortisation",
                "IPEP expense",
                "Disposals & impairment of fixed assets",
                "Profit on disposal of pooling equipment",
                "Scrapped pooling equipment",
                "Impairment or valuation adjustment of pooling equipment",
                "Disposals or valuation adjustments of other fixed assets",
                "Other cash flow from trading adjustments",
                "Share-based payments expense",
                "Working capital mvts excl. provisions",
                "Debtor movements",
                "Creditor movements",
                "Inventory movements",
                "Prepayment movements",
                "Provision movements",
                "Change in capex creditors",
                "Brambles allocations not in mgt cash flow",
                "Interco interest and guarantee fees",
                "Interco cash flows",
                "Interco royalties",
                "Statutory reallocations",
                "Internal restructuring",
                "Interco dividends Total",
                "Change in interco balances",
                "Change in interco recharge clearing",
                "FX on interco debt",
                "Interco capital returned",
                "Interco cash flow adjustments",
                "Interest expense Total",
                "Interest revenue",
                "Interest received",
                "Lease interest"
            }
        ) + CALCULATE(
            SUM(Bracs[Metric Value ($)]),
            Bracs[Metric] IN {
                "Pension plan adjustment",
                "Working capital - budget flex",
                "Pooling equipment additions",
                "Pooling equipment replacements",
                "Pooling equipment internal transfers",
                "Other PP&E additions",
                "Other PP&E replacements",
                "Other PP&E internal transfers",
                "Joint venture loans",
                "WDV pooling equip. disposals & write-offs",
                "Gain pooling equip. disposals & write-offs",
                "WDV other PP&E disposals",
                "Profit other PP&E disposals",
                "Discount unwind on long term provisions",
                "Tax paid",
                "Tax refunded",
                "Fiscal unity tax transfers",
                "Other cash flow items",
                "FX adjustments to cash flow",
				"Change in cash net of overdraft"
            }
        )
    )

@mspanic THANK YOU. It is working.
What do you mean by “so it’s calculate Next Paid Tax for all CashflowDiscriptions (not just description)”?

Also, CashFlowDescriptions contains all of the descriptions, while ZTBR’[Roll_Up_Function] and Bracs[Metric] only some. If i am calculating “Net tax paid” which is not in either of the two columns, i do not have to reference the CashflowDiscriptions table or so it seems?

@mspanic @HufferD

I am trying to do the same exercise for “Net debt increase/(decrease)”

Only the rows from Bracs display

Blockquote Net Debt Increase/Decrease2 =
VAR RelevantMetrics = {“Leases principal repaid”, “Change in cash net of overdraft”}
VAR LeasesAndCashChanges = CALCULATE(
SUM(Bracs[Metric Value ($)]),
Bracs[Metric] IN RelevantMetrics
)
VAR LoansDrawnDown = CALCULATE(
SUM(‘ZTBR’[Amount in USD]),
‘ZTBR’[Roll_Up_Function] = “Loans drawn down”
)
VAR LoanPrincipalRepaid = CALCULATE(
SUM(‘ZTBR’[Amount in USD]),
‘ZTBR’[Roll_Up_Function] = “Loan principal repaid”
)
RETURN
LeasesAndCashChanges + LoansDrawnDown - LoanPrincipalRepaid

Blockquote

Blockquote

@Yrstruly - pattern is the same

a) create measure you want (in first case NetTaxPaidTest , in second Net Debt Increase/Decrease2)

b) added in NewDisplay_Amount measure on 2 places

    1. to calculate Total
    1. display that Total where you want

image

To calculate total - you need to change context (since you want for all CashflowDiscriptions table attributes (to calculate for all description / accountcode that you show on your picture above)

if you need to add additional Total measure and put it in a line /description you could use that pattern.

New version of the measure (also with Net Debt Increase/Decrease2):

New CombinedAmount = 
VAR SelectedCashFlowDescription = SELECTEDVALUE('CashflowDiscriptions'[description], "None")
VAR _TotalNetDept =CALCULATE([Net Debt Increase/Decrease2], ALL(CashflowDiscriptions))
VAR _TotalNetTaxPaid =CALCULATE([NetTaxPaidTest], ALL(CashflowDiscriptions))
RETURN
    SWITCH(TRUE(),
        SelectedCashFlowDescription = "Interco capital returned", 678,
        SelectedCashFlowDescription = "Net debt increase/(decrease)", _TotalNetDept, 
        SelectedCashFlowDescription = "Net tax paid", _TotalNetTaxPaid, 
        CALCULATE(
            SUM('ZTBR'[Amount in USD]),
            'ZTBR'[Roll_Up_Function] IN {
                "Cash flow from ops - management",
                "Cash flow from trading",
                "Profit before Brambles allocations Total",
                "Depreciation and amortisation",
                "IPEP expense",
                "Disposals & impairment of fixed assets",
                "Profit on disposal of pooling equipment",
                "Scrapped pooling equipment",
                "Impairment or valuation adjustment of pooling equipment",
                "Disposals or valuation adjustments of other fixed assets",
                "Other cash flow from trading adjustments",
                "Share-based payments expense",
                "Working capital mvts excl. provisions",
                "Debtor movements",
                "Creditor movements",
                "Inventory movements",
                "Prepayment movements",
                "Provision movements",
                "Change in capex creditors",
                "Brambles allocations not in mgt cash flow",
                "Interco interest and guarantee fees",
                "Interco cash flows",
                "Interco royalties",
                "Statutory reallocations",
                "Internal restructuring",
                "Interco dividends Total",
                "Change in interco balances",
                "Change in interco recharge clearing",
                "FX on interco debt",
                "Interco capital returned",
                "Interco cash flow adjustments",
                "Interest expense Total",
                "Interest revenue",
                "Interest received",
                "Lease interest"
            }
        ) + CALCULATE(
            SUM(Bracs[Metric Value ($)]),
            Bracs[Metric] IN {
                "Pension plan adjustment",
                "Working capital - budget flex",
                "Pooling equipment additions",
                "Pooling equipment replacements",
                "Pooling equipment internal transfers",
                "Other PP&E additions",
                "Other PP&E replacements",
                "Other PP&E internal transfers",
                "Joint venture loans",
                "WDV pooling equip. disposals & write-offs",
                "Gain pooling equip. disposals & write-offs",
                "WDV other PP&E disposals",
                "Profit other PP&E disposals",
                "Discount unwind on long term provisions",
                "Tax paid",
                "Tax refunded",
                "Fiscal unity tax transfers",
                "Other cash flow items",
                "FX adjustments to cash flow",
				"Change in cash net of overdraft"
            }
        )
    )

Good luck with your project.

1 Like

@mspanic Thank you. Your code


Omitted now this row in this dax

BlockquoteNet Debt Increase/(Decrease) =
VAR LeasesPrincipalRepaid = CALCULATE(
SUM(‘Bracs’[Metric Value ($)]),
‘Bracs’[Metric] IN {“Leases principal repaid”, “Change in cash net of overdraft”}
)
RETURN
LeasesPrincipalRepaid

Also this calculation is suppose to read data from two sources. Although the second source dont have any values for the rows mentioned, i still would like to see them in the final dax. They are Loans drawn down,
Loan principal repaid.
image
These two additional rows are reading from table SUM(‘ZTBR’[Amount in USD]),
‘ZTBR’[Roll_Up_Function] IN**(should these values exist). Please note that Net debt increase/(decrease) is a total value and usually these rows only exist in table CashflowDiscriptions**

@Yrstruly if you want also to involve this new variable into calculation on that way it’s better to add this at the end of your first CombinedAmount measure from where we started.

So new version

New CombinedAmount = 
VAR SelectedCashFlowDescription = SELECTEDVALUE('CashflowDiscriptions'[description], "None")
VAR _TotalNetDept =CALCULATE([Net Debt Increase/Decrease2], ALL(CashflowDiscriptions))
VAR _TotalNetTaxPaid =CALCULATE([NetTaxPaidTest], ALL(CashflowDiscriptions))
RETURN
    SWITCH(TRUE(),
        SelectedCashFlowDescription = "Interco capital returned", 678,
        SelectedCashFlowDescription = "Net debt increase/(decrease)", _TotalNetDept, 
        SelectedCashFlowDescription = "Net tax paid", _TotalNetTaxPaid, 
        CALCULATE(
            SUM('ZTBR'[Amount in USD]),
            'ZTBR'[Roll_Up_Function] IN {
                "Cash flow from ops - management",
                "Cash flow from trading",
                "Profit before Brambles allocations Total",
                "Depreciation and amortisation",
                "IPEP expense",
                "Disposals & impairment of fixed assets",
                "Profit on disposal of pooling equipment",
                "Scrapped pooling equipment",
                "Impairment or valuation adjustment of pooling equipment",
                "Disposals or valuation adjustments of other fixed assets",
                "Other cash flow from trading adjustments",
                "Share-based payments expense",
                "Working capital mvts excl. provisions",
                "Debtor movements",
                "Creditor movements",
                "Inventory movements",
                "Prepayment movements",
                "Provision movements",
                "Change in capex creditors",
                "Brambles allocations not in mgt cash flow",
                "Interco interest and guarantee fees",
                "Interco cash flows",
                "Interco royalties",
                "Statutory reallocations",
                "Internal restructuring",
                "Interco dividends Total",
                "Change in interco balances",
                "Change in interco recharge clearing",
                "FX on interco debt",
                "Interco capital returned",
                "Interco cash flow adjustments",
                "Interest expense Total",
                "Interest revenue",
                "Interest received",
                "Lease interest"
            }
        ) + CALCULATE(
            SUM(Bracs[Metric Value ($)]),
            Bracs[Metric] IN {
                "Pension plan adjustment",
                "Working capital - budget flex",
                "Pooling equipment additions",
                "Pooling equipment replacements",
                "Pooling equipment internal transfers",
                "Other PP&E additions",
                "Other PP&E replacements",
                "Other PP&E internal transfers",
                "Joint venture loans",
                "WDV pooling equip. disposals & write-offs",
                "Gain pooling equip. disposals & write-offs",
                "WDV other PP&E disposals",
                "Profit other PP&E disposals",
                "Discount unwind on long term provisions",
                "Tax paid",
                "Tax refunded",
                "Fiscal unity tax transfers",
                "Other cash flow items",
                "FX adjustments to cash flow",
				"Change in cash net of overdraft"
            }
        ) +CALCULATE(
            SUM(Bracs[Metric Value ($)]),
            Bracs[Metric] IN {"Leases principal repaid", "Change in cash net of overdraft"}
    )
)

to get

So for the Total in a line pattern above, for selected metric value in a line simple add what you need at the end.

DAX is like a puzzle - piece by piece and you get what you need

@mspanic

The last added code is still part of =CALCULATE([Net Debt Increase/Decrease2], right?
Im curious why must it be added last since it is part of a variable mentioned in the beginning?

Please note table Cash flow descriptions contains text only and is used for referencing.
Im curious where the last added rows are getting their values from since they dont appear in the ZTBR table.

As you can see last added code is the formula that you provide it for Net Debt Increase/(Decrease)
as you additionally ask for.

As I mentioned you have two types :

  • Totals - you need to change the context and place additionally in a row where is needed

  • Selected metric value - in a line where is calculate without changing ‘original’ context.

Since the first post & question was answered - could you please close this thread?

If you have further questions could you open new one?

Many thanks.