Create a button to create rows with filtering

Hello,

I’m trying to have a button that could automatically create rows based on the values already existing in my table.

I have two tables,
One with raw data and one where i want aggregated data.

What I want for my button to do is to create a row in the aggregated data only if the line doesn’t exist yet.

I came up with this sort of formula :

[RawData].FormulaMap(
	WithName(
		currentValue, 
		currentRawData, 
		If(
			[AggregatedData].Filter(Month = currentRawData.Month).Count() > 0
			, ""
			, AddRow(
				[AggregatedData], 
				[AggregatedData].Month, 
				currentRawData.Month
			) 
		)
	)
)

If my table is empty and I have 3 values in the rawData, it will create three times the same raw. I guess there’s something like when creating the raw, it is not reflected in the running function.
But I don’t know how I could do this instead !

If anyoone has an advice ! happy to hear it :slight_smile:

Here is an example of my case
First time youo click you get 4 lines, second time, no actions !

Ok,
Actually I found it !
Instead of doing the FormulaMap all entries of the list, I first create a unique set of values I need.
That’s the formula in the end !

[Avancement par mois]
**.FormulaMap(List(Mois, Chiffrage.Evolution)).Unique()**
.FormulaMap(
	WithName(
		currentValue, 
		currentAvancement, 
		If(
			[Rapport mensuel].Filter(Mois = currentAvancement.nth(1) and Evolution = currentAvancement.nth(2)).Count() > 0
			, _Noop()
			, AddRow(
				[Rapport mensuel], 
				[Rapport mensuel].Mois, 
				currentAvancement.nth(1), 
				[Rapport mensuel].Evolution,
				currentAvancement.nth(2)
			) 
		)
	)
)