Forum Discussion
Every Month last day value
- 2 years ago
Yes Varan_15 - because of summation we are getting 86.22
monthname = FORMAT(LDY[Day],"mmm")Instead of that, you can convert the formaule by averagex and try to check the resultif it is monthly selection , what is expections.
Hope it helps
Hi Varan_15 - can you please share sample data as well in text format. will check at our end.
i have modified to take reference from calendar table.
Measure =
VAR SelectedMonths = VALUES('Calendar'[YearMonth])
VAR LastDays =
SUMMARIZE(
FILTER(
ALL('Calendar'),
'Calendar'[YearMonth] IN SelectedMonths
),
'Calendar'[YearMonth],
"LastDay", MAX('Calendar'[Date])
)
VAR Result =
SUMX(
LastDays,
CALCULATE(
SUM(Sales[Saving]),
Sales[Days] = [LastDay]
)
)
RETURN
Result
can you check above still error, please share sample copy of data(dummy) text copy .
Hope it works.
Still same error "Column 'LastDay' cannot be found or may not be used in this expression."
attached sample data here:
Day Area Branch Code Saving
16-May-24 CAPITAL 101 28.17
23-May-24 CAPITAL 101 29.22
30-May-24 CAPITAL 101 28.83
06-Jun-24 CAPITAL 101 26.73
13-Jun-24 CAPITAL 101 24.53
20-Jun-24 CAPITAL 101 23.53
30-Jun-24 CAPITAL 101 23.84
- rajendraongole12 years ago
Super User
Hi Varan_15 - Thanks for sharing,
Monthly Last Day Saving =VAR LastDayPerMonth =SUMMARIZE(LDY, // Replace 'LDY' with your actual table nameLDY[Area],LDY[Branch],"LastDay", MAX(LDY[Day]))VAR SumOfSavings =SUMX(LastDayPerMonth,VAR LastDayValue = [LastDay]RETURNCALCULATE(SUM(LDY[Code Saving]),LDY[Day] = LastDayValue))RETURNSumOfSavingscan you check the below measure: rename your table name and coumns
Hope it works
- Varan_152 years ago
Helper III
Thanks for your effort.
it's fetching month last day as expected but if i select MAY and JUN month using slicer then it should add total value ( 30th May value + 30th June value ) = 28.83+23.84 so total will be 52.67
based on month selection it should be sum of value.
Thanks,
MS
- rajendraongole12 years ago
Super User
Hi Varan_15 - create below two measure, one for last day of month another summation of each month selection.
replace table name as per your model.
Measure 1:
LastDayOfMonth =CALCULATE(MAX('LDY'[Day]),ALLEXCEPT('LDY', 'LDY'[Area], 'LDY'[Branch], 'LDY'[Day]))Measure 2:SumOfLastDayValues1 =SUMX(VALUES('LDY'[Day]),VAR LastDay =CALCULATE(MAX('LDY'[Day]),FILTER(ALL('LDY'),'LDY'[Day] <= MAX('LDY'[Day]) &&MONTH('LDY'[Day]) = MONTH(MAX('LDY'[Day])) &&YEAR('LDY'[Day]) = YEAR(MAX('LDY'[Day]))))RETURNIF('LDY'[Day] = LastDay,SUM('LDY'[Code Saving]),0))Output:if we select June 30if we select june and may below is the result.
Hope this works.