Forum Discussion
Last Half Yearly Data
- Anonymous2 years ago
Hi cyborgandy
Please try this:
First of all, I create a set of sample:
Then add a new measure:
MEASURE = VAR _selectDate = MAX ( 'Table'[Date] ) VAR _currentCompany = MAX ( 'Table'[Company] ) VAR _Half = FILTER ( ALL ( 'Table' ), MONTH ( 'Table'[Date] ) >= 1 && MONTH ( 'Table'[Date] ) <= 6 && YEAR ( 'Table'[Date] ) = YEAR ( _selectDate ) - 1 && 'Table'[Company] = _currentCompany ) VAR _Later = FILTER ( ALL ( 'Table' ), MONTH ( 'Table'[Date] ) >= 7 && MONTH ( 'Table'[Date] ) <= 12 && YEAR ( 'Table'[Date] ) = YEAR ( _selectDate ) - 1 && 'Table'[Company] = _currentCompany ) RETURN IF ( MONTH ( MAX ( 'Table'[Date] ) ) >= 1 && MONTH ( MAX ( 'Table'[Date] ) ) <= 6, CALCULATE ( SUM ( 'Table'[Value] ), _Half ), CALCULATE ( SUM ( 'Table'[Value] ), _Later ) )The result is as follow:
Best Regards
Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi cyborgandy
Please try this:
First of all, I create a set of sample:
Then add a new measure:
MEASURE =
VAR _selectDate =
MAX ( 'Table'[Date] )
VAR _currentCompany =
MAX ( 'Table'[Company] )
VAR _Half =
FILTER (
ALL ( 'Table' ),
MONTH ( 'Table'[Date] ) >= 1
&& MONTH ( 'Table'[Date] ) <= 6
&& YEAR ( 'Table'[Date] )
= YEAR ( _selectDate ) - 1
&& 'Table'[Company] = _currentCompany
)
VAR _Later =
FILTER (
ALL ( 'Table' ),
MONTH ( 'Table'[Date] ) >= 7
&& MONTH ( 'Table'[Date] ) <= 12
&& YEAR ( 'Table'[Date] )
= YEAR ( _selectDate ) - 1
&& 'Table'[Company] = _currentCompany
)
RETURN
IF (
MONTH ( MAX ( 'Table'[Date] ) ) >= 1
&& MONTH ( MAX ( 'Table'[Date] ) ) <= 6,
CALCULATE ( SUM ( 'Table'[Value] ), _Half ),
CALCULATE ( SUM ( 'Table'[Value] ), _Later )
)
The result is as follow:
Best Regards
Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi could you please share the working pbi file to understand more about this DAX 🙂
- Anonymous2 years agoNot applicable
Hi cyborgandy
Blow is the pbix.
Best Regards
Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.