Forum Discussion
Rows transformation to columns
- 5 years ago
Hi Anonymous ,
It is suggested to create another table like below:
Order Columns 1 202001 2 202002 ... ...
12 202012
13 2020-Total
14 202101
... ...
25 202112
26 2021-Total
... ...
And then, sort "Columns" column by "Order" column and put "Columns" column into Columns field of the Matrix visual. Then, create a measure like below and put it into Values field:
Measure = VAR Year_ = LEFT ( MAX ( 'Data'[DATE_ICD] ), 4 ) VAR Columns_ = MAX ( 'Table'[Columns] ) RETURN IF ( Columns_ = "2020-Total", CALCULATE ( SUM ( 'Data'[Amount] ), Year_ = "2020" ), IF ( Columns_ = "2021-Total", CALCULATE ( SUM ( 'Data'[Amount] ), Year_ = "2021" ), CALCULATE ( SUM ( 'Data'[Amount] ), 'Data'[DATE_ICD] = Columns_ ) ) )Best regards
Icey
If this post helps, then consider Accepting it as the solution to help other members find it faster.
Here's what I would do:
in Power Query add a date column that represents the first day of the month.
= Table.AddColumn(#"Renamed Columns", "Day", each Date.FromText(Text.Start([DATE_ICD],4) & "-" & Text.End([DATE_ICD],2) & "-01"))
Then you can format that column in Power BI to anything you want, including MMM.YY
- Anonymous5 years agoNot applicable
Hi lbendlin ,
I tried to use the same formula in my query editor but it throwing an error. Could you tell me what I am doing wrong here?