我需要创建以下矩阵,其中如果它是开始或月末,则我汇总类别1中的A或B并计算SUM,但是如果它是一个月中除第一天或最后一天之外的任何一天,我要进行标记类别2中的A或B并计算SUM。我想我需要使用SWITCH,不是吗?
根据评论编辑信息
就像创建3个col一样:
isStart = IF ( main_table[date] = STARTOFMONTH ( main_table[date] ), 1, 0 )
isEnd = IF ( main_table[date] = ENDOFMONTH ( 'main_table'[date] ), 1, 0 )
in_between_date =
IF ( AND ( main_table[date] <> ENDOFMONTH ( 'main_table'[date] ),
main_table[date] <> STARTOFMONTH ( main_table[date] ) ), 1, 0 )
然后,用我的类别创建列,例如
start_end =
IF ( OR ( NOT ( ISERROR ( SEARCH ( "A", main_table[code] ) ) ),
main_table[code] = "B" ),
"Category 1",
BLANK () )
和
in_between =
IF ( OR ( main_table[code] = "B", main_table[code] = "A" ), "Category 2", BLANK () )
但是,那我应该在switch / if中使用什么呢? = if(VALUES('main_table'[isStart]) = 1
,然后呢?