Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Filter sum column by category

I want to create a slicer of categories so that I can see the evolution of the portfolio by period. Any idea how to do it for the example below?

 

PeriodPortfolio (A+B+C)Category ACategory BCategory C
jan-191406490455461
feb-191297485361451
mrt-19941339280322
apr-191030460321249
mei-19915190316409
jun-19569164293112
jul-19929192368369
aug-191429458471500
sep-191155405300450
okt-19778123290365
nov-19951415344192
dec-19886207404275

 

2 ACCEPTED SOLUTIONS
jthomson
Solution Sage
Solution Sage

Go into Power Query, get rid of the sum column, then unpivot the individual category columns so you have:

 

period - category - value

jan-19 - a - 490

jan-19 - b - 455

jan-19 - c - 461

feb-19 - a - 485

 

etc - the category column can then just be dropped into a slicer as you want

View solution in original post

v-frfei-msft
Community Support
Community Support

Hi @Anonymous ,

 

1. Unpivot the table.

Capture.PNG

 

M code for your reference.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("RZC5bgMxDET/ZWsbIEXqYGkgSOEijUvDRRIsgiCHDSPO91sz2k0aSiCfRjM8HieN7f75e9pM6lL64SGoOaMWnU4bMo/zC5gUFf2GqfUpyMF8XX+2Gr0RjrYZ7qlBzFJaZXaXK2TE+EkZU/DJY8jM74uM4g+lG1M6k1hl9jc4zgWgFsf7MNw1/SOfUElEItFvY/1T2d3emJuMZ0y9wkwWWZnDfKHu2Icwt4wNDeb8seSutXFDRje0XfIq83T+hZvMjTGZuS/OFuRhfu2N1hA1CdcsTFa7yukO", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Period = _t, #"Portfolio (A+B+C)" = _t, #"Category A" = _t, #"Category B" = _t, #"Category C" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Period", type text}, {"Portfolio (A+B+C)", Int64.Type}, {"Category A", Int64.Type}, {"Category B", Int64.Type}, {"Category C", Int64.Type}}),
    #"Removed Columns" = Table.RemoveColumns(#"Changed Type",{"Portfolio (A+B+C)"}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Removed Columns", {"Period"}, "Attribute", "Value")
in
    #"Unpivoted Other Columns"

 

 

2. Then we can see the evolution of the portfolio by period.

2.PNG

 

For more details, please check the pbix as attached.

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

3 REPLIES 3
v-frfei-msft
Community Support
Community Support

Hi @Anonymous ,

 

1. Unpivot the table.

Capture.PNG

 

M code for your reference.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("RZC5bgMxDET/ZWsbIEXqYGkgSOEijUvDRRIsgiCHDSPO91sz2k0aSiCfRjM8HieN7f75e9pM6lL64SGoOaMWnU4bMo/zC5gUFf2GqfUpyMF8XX+2Gr0RjrYZ7qlBzFJaZXaXK2TE+EkZU/DJY8jM74uM4g+lG1M6k1hl9jc4zgWgFsf7MNw1/SOfUElEItFvY/1T2d3emJuMZ0y9wkwWWZnDfKHu2Icwt4wNDeb8seSutXFDRje0XfIq83T+hZvMjTGZuS/OFuRhfu2N1hA1CdcsTFa7yukO", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Period = _t, #"Portfolio (A+B+C)" = _t, #"Category A" = _t, #"Category B" = _t, #"Category C" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Period", type text}, {"Portfolio (A+B+C)", Int64.Type}, {"Category A", Int64.Type}, {"Category B", Int64.Type}, {"Category C", Int64.Type}}),
    #"Removed Columns" = Table.RemoveColumns(#"Changed Type",{"Portfolio (A+B+C)"}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Removed Columns", {"Period"}, "Attribute", "Value")
in
    #"Unpivoted Other Columns"

 

 

2. Then we can see the evolution of the portfolio by period.

2.PNG

 

For more details, please check the pbix as attached.

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
Anonymous
Not applicable

As suggested, remove the Portfolio column and unpivot the table on Period, then use the Category column in the slicer.

jthomson
Solution Sage
Solution Sage

Go into Power Query, get rid of the sum column, then unpivot the individual category columns so you have:

 

period - category - value

jan-19 - a - 490

jan-19 - b - 455

jan-19 - c - 461

feb-19 - a - 485

 

etc - the category column can then just be dropped into a slicer as you want

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.