Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more.
Get startedGrow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.
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 sales for the segmented month, but also for the month before and after the selected month. What expression would the new measure have?
Thank you
Solved! Go to Solution.
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 Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
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 Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Please add a calendar table to your data model.
User | Count |
---|---|
81 | |
79 | |
70 | |
70 | |
54 |
User | Count |
---|---|
107 | |
99 | |
88 | |
79 | |
67 |