The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
Hello,
I am sure this has been address.
I've hacked away at this forum but could not find the response.
Current Situaiton
Problem
Thx in advance for all your help.
Hi,
this is one way of solving your issue, although sligthly verbose:
MeasureCurrentYear cumulative =
VAR _year =
CALCULATE ( SELECTEDVALUE ( Dates[Year] ) )
VAR _month =
CALCULATE ( SELECTEDVALUE ( Dates[MonthNum] ) )
VAR _maxMonthCurrentYear =
CALCULATE (
MAX ( 'Table'[month] ),
FILTER ( ALL ( 'Table' ), 'Table'[Year] = _year )
)
RETURN
IF (
_month <= _maxMonthCurrentYear
&& HASONEVALUE ( Dates[Month] ),
CALCULATE (
SUM ( 'Table'[NumberOfPassengers] ),
FILTER ( ALL ( Dates ), Dates[Year] = _year && Dates[MonthNum] <= _month )
),
IF (
NOT ( HASONEVALUE ( Dates[Month] ) ),
SUMX (
CALCULATETABLE (
'Table',
FILTER (
ALL ( 'Table' ),
'Table'[Year] = _year
&& 'Table'[month] <= _maxMonthCurrentYear
)
),
'Table'[NumberOfPassengers]
),
BLANK ()
)
)
MeasureCurrentYear-1 cumulative =
VAR _year =
CALCULATE ( SELECTEDVALUE ( Dates[Year] ) )
VAR _month =
CALCULATE ( SELECTEDVALUE ( Dates[MonthNum] ) )
VAR _maxMonthCurrentYear =
CALCULATE (
MAX ( 'Table'[month] ),
FILTER ( ALL ( 'Table' ), 'Table'[Year] = _year )
)
RETURN
IF (
_month <= _maxMonthCurrentYear
&& HASONEVALUE ( Dates[Month] ),
CALCULATE (
SUM ( 'Table'[NumberOfPassengers] ),
FILTER ( ALL ( Dates ), Dates[Year] = _year - 1 && Dates[MonthNum] <= _month )
),
IF (
NOT ( HASONEVALUE ( Dates[Month] ) ),
SUMX (
CALCULATETABLE (
'Table',
FILTER (
ALL ( 'Table' ),
'Table'[Year] = _year - 1
&& 'Table'[month] <= _maxMonthCurrentYear
)
),
'Table'[NumberOfPassengers]
),
BLANK ()
)
)
User | Count |
---|---|
65 | |
62 | |
60 | |
53 | |
28 |
User | Count |
---|---|
181 | |
82 | |
67 | |
47 | |
44 |