#Code comment
by_year <- combined_pivot %>%
mutate('202011' = case_when(Fiscal_Month<= 202011 ~ `Sum of Negative Expired seats`,
TRUE ~ 0),
'202012' = case_when(Fiscal_Month<= 202012 ~ `Sum of Negative Expired seats`,
TRUE ~ 0),
'202101' = case_when(Fiscal_Month<= 202101 ~ `Sum of Negative Expired seats`,
TRUE ~ 0),
'202102' = case_when(Fiscal_Month<= 202102 ~ `Sum of Negative Expired seats`,
TRUE ~ 0),
'202103' = case_when(Fiscal_Month<= 202103 ~ `Sum of Negative Expired seats`,
TRUE ~ 0),
'202104' = case_when(Fiscal_Month<= 202104 ~ `Sum of Negative Expired seats`,
TRUE ~ 0),
'202105' = case_when(Fiscal_Month<= 202105 ~ `Sum of Negative Expired seats`,
TRUE ~ 0))
I am not sure what your original data looks like, but the column names seems from the "unique" value of one column, consider
pivot_wider ()
1 Like
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.
If you have a query related to it or one of the replies, start a new topic and refer back with a link.