Forum Discussion
Measure on different columns
- 7 years ago
Hi Noivilbo
You may create below two measures:
LastAmountSum = VAR Lase_date = CALCULATE ( MAX ( Salestable[Date] ), FILTER ( ALL ( Datetable ), Datetable[Date] < MAX ( Salestable[Date] ) ) ) RETURN CALCULATE ( SUM ( Salestable[Amount] ), FILTER ( ALL ( Datetable ), Datetable[Date] = Lase_date ) ) + CALCULATE ( SUM ( Salestable[Amount] ) )Measure = VAR Max_date = CALCULATE ( MAX ( Salestable[Date] ), FILTER ( ALL ( Salestable ), Salestable[Date] <= MAX ( Datetable[Date] ) ) ) RETURN SUMX ( FILTER ( ALL ( Datetable ), Datetable[Date] = Max_date ), [LastAmountSum] )Regards,
- 7 years ago
Hi Noivilbo
You may check the attached sample file.The formula are measures.If it is not your case,please update the sample data(add the third client) and explain more about how to get your expected output.
Regards,
Hi Noivilbo
You may create below two measures:
LastAmountSum =
VAR Lase_date =
CALCULATE (
MAX ( Salestable[Date] ),
FILTER ( ALL ( Datetable ), Datetable[Date] < MAX ( Salestable[Date] ) )
)
RETURN
CALCULATE (
SUM ( Salestable[Amount] ),
FILTER ( ALL ( Datetable ), Datetable[Date] = Lase_date )
)
+ CALCULATE ( SUM ( Salestable[Amount] ) )
Measure =
VAR Max_date =
CALCULATE (
MAX ( Salestable[Date] ),
FILTER ( ALL ( Salestable ), Salestable[Date] <= MAX ( Datetable[Date] ) )
)
RETURN
SUMX (
FILTER ( ALL ( Datetable ), Datetable[Date] = Max_date ),
[LastAmountSum]
)
Regards,
Hi,
Thanks for your input;
I have 2 further questions though, maybe because I don't fully understand the code:
1) Any idea why I get 20 already in the first row, when I use your code - rather than the 5 I would need, and that is included in your printscreen?
2) It seems that you take the last matching date until the date of the row itself, and manually add the sum of the row itself. However, I would need to end up using the last amount per client (i.e. if I add data for a third client, the code doesn't seem to pick this up. I would expect that somewhere in the code, we would actively work with the "client" column?)
Thanks!
- v-cherch-msft7 years agoMicrosoft Employee
Hi Noivilbo
You may check the attached sample file.The formula are measures.If it is not your case,please update the sample data(add the third client) and explain more about how to get your expected output.
Regards,