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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
excelso21
Frequent Visitor

Remaining Amount Sum

I have a situation where I have to sum the remaining values of a certain model.

 

My Table in the data model looks like this:

 ID Value Date    Amount  Creation Date
1   01/01/2018      1 000      01/01/2018
2   01/02/2018      1 000      01/01/2018
3   01/03/2018      1 000      01/01/2018
4   01/04/2018      1 000      01/01/2018
5   01/05/2018      1 000      01/05/2018
6   01/06/2018      1 000      01/01/2018
7   01/07/2018       0

 

The goal is to have a measure Remaining Value that would have this output:

Date   Remaining Value
Jan       5 000
Fev       4 000
Mar      3 000
Abr      2 000
Mai      2 000
Jun      1 000
Jul            0

 

Value Date is related to my calendar table.

In Jan, the logic is Sum Value Date >= 01/01/2018 with Creation Date >= 01/01/2018 and Creation Date<01/05/2018...

 

I tried the measure like this but is not working:

Remaining Value:=calculate(
			sum[Amount];
			filter(
				all('Calendar'[Date]);
				'Calendar'[Date]>max('Calendar'[Date]) &&
				'Calendar'[Date]<=max(Table[Creation Date]
			)
			)
1 ACCEPTED SOLUTION
v-ljerr-msft
Microsoft Employee
Microsoft Employee

Hi @excelso21,

 

If I understand you correctly, the formula below should work in your scenario. Smiley Happy

Measure = 
VAR firstDateOfMonth =
    FIRSTDATE ( 'Calendar'[Date] )
VAR maxCreationDate =
    MAX ( Table1[Creation Date] )
RETURN
    CALCULATE (
        SUM ( Table1[Amount] ),
        FILTER (
            Table1,
            Table1[Creation Date] >= firstDateOfMonth
                && Table1[Creation Date] < maxCreationDate
        )
    )

 

Regards

View solution in original post

3 REPLIES 3
v-ljerr-msft
Microsoft Employee
Microsoft Employee

Hi @excelso21,

 

If I understand you correctly, the formula below should work in your scenario. Smiley Happy

Measure = 
VAR firstDateOfMonth =
    FIRSTDATE ( 'Calendar'[Date] )
VAR maxCreationDate =
    MAX ( Table1[Creation Date] )
RETURN
    CALCULATE (
        SUM ( Table1[Amount] ),
        FILTER (
            Table1,
            Table1[Creation Date] >= firstDateOfMonth
                && Table1[Creation Date] < maxCreationDate
        )
    )

 

Regards

Thanks. It worked.

 

Alternatevily I figured out also this measure:

Measure:=-calculate(
			sum(Table1[Amount] );
			filter(
				all('Calendar');
				'Calendar'[Date]>max('Calendar'[Date])
				);
			filter(
				all(Table1[Creation Date]);
				Table1[Creation Date]<=max('Calendar'[Date])
			)					
)

 

excelso21
Frequent Visitor

Hello, it is my first post so sorry if I don't use this Community standards.

 

I have a situation where I have to sum the remaining values of a certain model.

 

My Table in the data model looks like this:

 ID Value Date    Amount  Creation Date
1   01/01/2018      1 000      01/01/2018
2   01/02/2018      1 000      01/01/2018
3   01/03/2018      1 000      01/01/2018
4   01/04/2018      1 000      01/01/2018
5   01/05/2018      1 000      01/05/2018
6   01/06/2018      1 000      01/01/2018
7   01/07/2018       0

 

The goal is to have a measure Remaining Value that would have this output:

Date   Remaining Value
Jan       5 000
Fev       4 000
Mar      3 000
Abr      2 000
Mai      2 000
Jun      1 000
Jul            0

Value Date is related to my calendar table.

In Jan, the logic is Sum Value Date >= 01/01/2018 with Creation Date >= 01/01/2018 and Creation Date<01/05/2018...

 

I tried the measure like this but is not working:

 
Remaining Value:=calculate(
   sum[Amount];
   filter(
    all('Calendar'[Date]);
    'Calendar'[Date]>max('Calendar'[Date]) &&
    'Calendar'[Date]<=max(Table[Creation Date]
   )
   )

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.