Forum Discussion
sum if sum
- 3 years ago
Hi markcabantog ,
According to your description, here's my solution.
1.The two tables are related with Date column.
2.Create a calculated column in Data table.
WeekNo = RELATED('Date'[WeekNo])2.Create a measure.
Measure = VAR _T = ADDCOLUMNS ( 'Data', "Flag", IF ( SUMX ( FILTER ( 'Data', 'Data'[WeekNo] = EARLIER ( 'Data'[WeekNo] ) ), 'Data'[Sales] ) > 15, 1, 0 ) / COUNTROWS ( FILTER ( 'Data', 'Data'[Veg] = EARLIER ( 'Data'[Veg] ) && 'Data'[WeekNo] = EARLIER ( 'Data'[WeekNo] ) ) ) ) RETURN SUMX ( _T, [Flag] )Get the correct result:
I attach my sample below for your reference.
Best Regards,
Community Support Team _ kalyjIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi markcabantog ,
According to your description, here's my solution.
1.The two tables are related with Date column.
2.Create a calculated column in Data table.
WeekNo = RELATED('Date'[WeekNo])
2.Create a measure.
Measure =
VAR _T =
ADDCOLUMNS (
'Data',
"Flag",
IF (
SUMX (
FILTER ( 'Data', 'Data'[WeekNo] = EARLIER ( 'Data'[WeekNo] ) ),
'Data'[Sales]
) > 15,
1,
0
)
/ COUNTROWS (
FILTER (
'Data',
'Data'[Veg] = EARLIER ( 'Data'[Veg] )
&& 'Data'[WeekNo] = EARLIER ( 'Data'[WeekNo] )
)
)
)
RETURN
SUMX ( _T, [Flag] )
Get the correct result:
I attach my sample below for your reference.
Best Regards,
Community Support Team _ kalyj
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.