Forum Discussion
JoãoBerryBR
7 years agoNew Member
Project completion date VS BY calendar - Projects impacts
Hi all, How to implement if with powerquery codes? I´d like to make a "date" formate data calculation, the proposal is to measure the impact of some projects, based on the Completion Date vs the...
- 7 years ago
Hi JoãoBerryBR
Create a calendar table without creating any relationship
calendar = ADDCOLUMNS(CALENDARAUTO(),"modified year",IF(MONTH([Date])<10,YEAR([Date]),YEAR([Date])+1))
Create measures in main data table
measure = VAR end_2018 = CALCULATE ( MAX ( 'calendar'[Date] ), FILTER ( ALL ( 'calendar' ), 'calendar'[modified year] = 2018 ) ) VAR end_2019 = CALCULATE ( MAX ( 'calendar'[Date] ), FILTER ( ALL ( 'calendar' ), 'calendar'[modified year] = 2019 ) ) RETURN IF ( MAX ( 'Table'[Anticipated Completion Date] ) > end_2019, 0, IF ( MAX ( 'Table'[Anticipated Completion Date] ) <= end_2018, IF ( 365 - DATEDIFF ( MAX ( 'Table'[Anticipated Completion Date] ), end_2018, DAY ) >= 0, 365 - DATEDIFF ( MAX ( 'Table'[Anticipated Completion Date] ), end_2018, DAY ), 0 ), DATEDIFF ( MAX ( 'Table'[Anticipated Completion Date] ), end_2019, DAY ) ) )Best Regards
MaggieCommunity Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-juanli-msft
7 years agoCommunity Support
Hi JoãoBerryBR
Create a calendar table without creating any relationship
calendar = ADDCOLUMNS(CALENDARAUTO(),"modified year",IF(MONTH([Date])<10,YEAR([Date]),YEAR([Date])+1))
Create measures in main data table
measure =
VAR end_2018 =
CALCULATE (
MAX ( 'calendar'[Date] ),
FILTER ( ALL ( 'calendar' ), 'calendar'[modified year] = 2018 )
)
VAR end_2019 =
CALCULATE (
MAX ( 'calendar'[Date] ),
FILTER ( ALL ( 'calendar' ), 'calendar'[modified year] = 2019 )
)
RETURN
IF (
MAX ( 'Table'[Anticipated Completion Date] ) > end_2019,
0,
IF (
MAX ( 'Table'[Anticipated Completion Date] ) <= end_2018,
IF (
365 - DATEDIFF ( MAX ( 'Table'[Anticipated Completion Date] ), end_2018, DAY ) >= 0,
365 - DATEDIFF ( MAX ( 'Table'[Anticipated Completion Date] ), end_2018, DAY ),
0
),
DATEDIFF ( MAX ( 'Table'[Anticipated Completion Date] ), end_2019, DAY )
)
)
Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
JoãoBerryBR
7 years agoNew Member
Thank you, I will try it.
Kind regards,