Forum Discussion
Month on Month difference table visual that's sortable
Hi OffColour1972,
A matrix isn't really suited to this if you need every displayed column to be independently sortable. The column headers in your example are part of the matrix structure, so Power BI doesn't treat them like normal table columns for sorting.
If the months are known/fixed, I'd use a Table visual instead and create separate measures for each value you want to display.
For example:
March Total =
CALCULATE(
SUM(Sales[Amount]),
'Date'[Month] = "March"
)
April Total =
CALCULATE(
SUM(Sales[Amount]),
'Date'[Month] = "April"
)
March-April Diff =
[April Total] - [March Total]
Then put Species plus those measures into a Table visual:
Species | March Total | April Total | March-April Diff | May Total | ...
With a Table visual, the user can click the individual column headers and sort by that particular measure.
If the months need to be completely dynamic, that's where it gets more complicated. A matrix is better for dynamically generating the month columns, but you lose some of the straightforward column-by-column sorting you're looking for.
So for a fixed number of months, I'd go with a Table + measures. If the months need to change dynamically based on the data/selection, I'd look at a different design using calculation groups or field parameters.