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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
giuliapiazza94
Helper IV
Helper IV

Total previous month as initian total current month

Hi guys,

I've a table like this

 

dateTypeQty
01/01/2024A2
01/01/2024B-1
01/01/2024B-8
01/01/2024B-3
01/01/2024A9
01/01/2024A10
01/02/2024A5
01/02/2024B-1
01/02/2024B-2
01/03/2024A6
01/03/2024A7
01/03/2024B-2

 

i need to calculate total A and total B for each month. The total of last month must be the inizial total of current month. For example:

 

giuliapiazza94_0-1725433441694.png

In january the total is 9.

The initial value in february is 9 --> 9 + 5 - 3 = 11

The initial value in march is 11... etc etc

 

How Can i replicate this table?

 

Thank you all 🙂

1 ACCEPTED SOLUTION
Dangar332
Super User
Super User

Hi, @giuliapiazza94 

Try below measure

 

Measure = 
	VAR a = SUMX(
		FILTER(
			ALLSELECTED(
				'Table'[date],
				'Table'[Qty]
			),
			'Table'[date] <= MAXX(
				FILTER(
					ALLSELECTED('Table'[date]),
					'Table'[date] < MIN('Table'[date])
				),
				[date]
			)
		),
		'Table'[Qty]
	)
	VAR b = SUM('Table'[Qty]) + a
	RETURN
		IF(
			ISINSCOPE('Table'[Type]),
			SUM('Table'[Qty]),
			b
		)

 

 

Dangar332_0-1725435994531.png


You can download .pbix file.

 

Best Regards,
Dangar

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.



View solution in original post

1 REPLY 1
Dangar332
Super User
Super User

Hi, @giuliapiazza94 

Try below measure

 

Measure = 
	VAR a = SUMX(
		FILTER(
			ALLSELECTED(
				'Table'[date],
				'Table'[Qty]
			),
			'Table'[date] <= MAXX(
				FILTER(
					ALLSELECTED('Table'[date]),
					'Table'[date] < MIN('Table'[date])
				),
				[date]
			)
		),
		'Table'[Qty]
	)
	VAR b = SUM('Table'[Qty]) + a
	RETURN
		IF(
			ISINSCOPE('Table'[Type]),
			SUM('Table'[Qty]),
			b
		)

 

 

Dangar332_0-1725435994531.png


You can download .pbix file.

 

Best Regards,
Dangar

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.



Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.