Forum Discussion
Matrix, Mixing Columns (For example Months, then Quarters as columns)
- Anonymous7 years ago
Hi DebbieE ,
You can create a custom sort table with all month and quarters and setting 'sort by column' feature on these fields.
Sort table = SELECTCOLUMNS ( GENERATESERIES ( 1, 16, 1 ), "Index", [Value], "Desc", IF ( [Value] <= 12, FORMAT ( DATEVALUE ( [Value] & "/1/2019" ), "mmm" ), "Q" & [Value] - 12 ) )After these steps, you can use original matrix row with new table fields to create a matrix. For value fields, you can write a measure to calculate correspond result based on current category and column label.
Measure = VAR currLable = MAX ( 'Sort Table'[Desc] ) RETURN IF ( currLable IN { "Q1", "Q2", "Q3", "Q4" }, CALCULATE ( SUM ( table[Amount] ), FILTER ( ALLSELECTED ( Table ), MONTH ( [Date] ) >= RIGHT ( currLable, 1 ) * 3 - 2 && MONTH ( [Date] ) <= RIGHT ( currLable, 1 ) * 3 ), VALUES ( Table[Group] ) ), CALCULATE ( SUM ( table[Amount] ), FILTER ( ALLSELECTED ( Table ), FORMAT ( [Date], "mmm" ) = currLable ), VALUES ( Table[Group] ) ) )Regards,
Xiaoxin Sheng
Hi DebbieE ,
You can create a custom sort table with all month and quarters and setting 'sort by column' feature on these fields.
Sort table =
SELECTCOLUMNS (
GENERATESERIES ( 1, 16, 1 ),
"Index", [Value],
"Desc", IF (
[Value] <= 12,
FORMAT ( DATEVALUE ( [Value] & "/1/2019" ), "mmm" ),
"Q" & [Value] - 12
)
)
After these steps, you can use original matrix row with new table fields to create a matrix. For value fields, you can write a measure to calculate correspond result based on current category and column label.
Measure =
VAR currLable =
MAX ( 'Sort Table'[Desc] )
RETURN
IF (
currLable IN { "Q1", "Q2", "Q3", "Q4" },
CALCULATE (
SUM ( table[Amount] ),
FILTER (
ALLSELECTED ( Table ),
MONTH ( [Date] )
>= RIGHT ( currLable, 1 ) * 3 - 2
&& MONTH ( [Date] )
<= RIGHT ( currLable, 1 ) * 3
),
VALUES ( Table[Group] )
),
CALCULATE (
SUM ( table[Amount] ),
FILTER ( ALLSELECTED ( Table ), FORMAT ( [Date], "mmm" ) = currLable ),
VALUES ( Table[Group] )
)
)
Regards,
Xiaoxin Sheng
- DebbieE7 years ago
Community Champion
thanks for that but I think thats way too complex for me to add into the design of the report.
Ill have to think of an easier way