cancel
Showing results for
Did you mean:

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Frequent Visitor

## Make a total for maxx values (Balance sheet)

Hello, community. I've created Balance Sheet with the following formula:
Return actual balance =
VAR maxDate = MAX('BS_actuals'[date_key])

RETURN
MAXX(FILTER(BS_actuals,[date_key]=maxDate),[value])

This way, when choosing a range of dates, it didn't sum up all the balances, but returned the balance for the latest date of selected dates range. That worked for 1 level of balances. However, when I add the level above (grand level), it doesn't sum up but get the maxx amount for the entire level.

1 ACCEPTED SOLUTION
Super User

@YeldarR , Try like

Return actual balance =
VAR maxDate = MAXX(allselected('BS_actuals') , 'BS_actuals'[date_key])

RETURN
SUMX(FILTER(BS_actuals,[date_key]=maxDate),[value])

or

Return actual balance =
VAR maxDate = MAXX(allselected('BS_actuals') , 'BS_actuals'[date_key])

RETURN
SUMX(values(BS_actuals[Level1]), calculate( MAXX(FILTER(BS_actuals,[date_key]=maxDate),[value]) ) )

4 REPLIES 4
Super User

@YeldarR , Try like

Return actual balance =
VAR maxDate = MAXX(allselected('BS_actuals') , 'BS_actuals'[date_key])

RETURN
MAXX(FILTER(BS_actuals,[date_key]=maxDate),[value])

If this does not help
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Frequent Visitor

Thank you. Nope doesn't work. It works only for level1 layout, but level2 layout show maxx instead of sum.

BS actuals goes the following:

BS layout:

Super User

@YeldarR , Try like

Return actual balance =
VAR maxDate = MAXX(allselected('BS_actuals') , 'BS_actuals'[date_key])

RETURN
SUMX(FILTER(BS_actuals,[date_key]=maxDate),[value])

or

Return actual balance =
VAR maxDate = MAXX(allselected('BS_actuals') , 'BS_actuals'[date_key])

RETURN
SUMX(values(BS_actuals[Level1]), calculate( MAXX(FILTER(BS_actuals,[date_key]=maxDate),[value]) ) )

Frequent Visitor

Thank you!

First one is correct.

Everyone who complies balance sheet, must use this command to get balances correct:

Return actual balance =
VAR maxDate = MAXX(allselected('BS_actuals') , 'BS_actuals'[date_key])

RETURN
SUMX(FILTER(BS_actuals,[date_key]=maxDate),[value])