Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
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 |
---|---|
85 | |
77 | |
68 | |
49 | |
41 |
User | Count |
---|---|
111 | |
56 | |
50 | |
42 | |
40 |