Forum Discussion
Syndicate_Admin
Administrator
3 years agoFILTER
Hello! I have a table where I have a month number field and a year number field. I do segmentation with year number and month number. (There is no calendar table). I want to calculate the total sale...
- Anonymous3 years ago
Hi Syndicate_Admin ,
I suggest you to add a YearMonth column in your data table and then create measures to achieve your goal.
Previous Month Value = VAR _PREVIOUS = CALCULATE ( MAX ( 'Table'[YearMonth] ), FILTER ( ALL ( 'Table' ), 'Table'[YearMonth] < MAX ( 'Table'[YearMonth] ) ) ) RETURN CALCULATE ( SUM ( 'Table'[Value] ), FILTER ( ALL ( 'Table' ), 'Table'[YearMonth] = _PREVIOUS ) )Future Month Value = VAR _Future = CALCULATE ( MIN ( 'Table'[YearMonth] ), FILTER ( ALL ( 'Table' ), 'Table'[YearMonth] > MAX ( 'Table'[YearMonth] ) ) ) RETURN CALCULATE ( SUM ( 'Table'[Value] ), FILTER ( ALL ( 'Table' ), 'Table'[YearMonth] = _Future ) )Result is as below.
Best Regards,
Rico ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
lbendlin
Super User
3 years agoPlease add a calendar table to your data model.