Forum Discussion
ryanxngo
2 years agoNew Member
FILTER using column values instead of a scalar value
I am trying to create a cumulative sum measure using the following formula: Cumulative_Cash = VAR CurrentRowDate = MAX(FactSales[CalendarDate]) VAR SelectedGrains = VALUES(FactSales[Grain]) ...
- 2 years ago
hi ryanxngo ,
try like:
1) add a calculated column like:
MonthNO = FORMAT([Date], "YYYYMM")2) plot a table visual with month column and a measure like:
C_Cash = SUMX( FILTER( ALLSELECTED(data), data[MonthNO]<=MAX(data[MonthNO]) ), data[Cash] )or
C_Cash2 = CALCULATE( SUM(data[Cash]), ALLSELECTED(data), data[MonthNO]<=MAX(data[MonthNO]) )it worked like:
ryanxngo
2 years agoNew Member
Hi ValtteriN,
Thank you so much, I thought this had worked for me but seems like there's one more issue:
I have a month columns based on Date so if I use the Month column the cumulative sum doesn't work as expected
Here is my dataset:
The formula that I used:
C_Cash =
VAR CurrentRowDate = MAX(FactSales[Date])
RETURN
CALCULATE(
SUM(FactSales[Total_Cash]),
ALL(FactSales[Date]),
FactSales[Date] <= CurrentRowDate
)
I hope you can help me with this as well, thanks
FreemanZ
Super User
2 years agohi ryanxngo ,
try like:
1) add a calculated column like:
MonthNO = FORMAT([Date], "YYYYMM")
2) plot a table visual with month column and a measure like:
C_Cash =
SUMX(
FILTER(
ALLSELECTED(data),
data[MonthNO]<=MAX(data[MonthNO])
),
data[Cash]
)
or
C_Cash2 =
CALCULATE(
SUM(data[Cash]),
ALLSELECTED(data),
data[MonthNO]<=MAX(data[MonthNO])
)
it worked like: