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
MiekeV
Frequent Visitor

Data Formatting for Slicer

Hi All,

 

TL;DR

How can I create a slicer for both month and year?

 

I'm a co-op student working on an accounting project for a company.

 

The data that I am using is being pulled directly from SQL but I have created a table in Excel to better represent my issue.

Currently, the data is formatted similarly to the image. Each month has its own column and there is also a column for the year.

I am hoping to be able to create a slicer for both month and year. To create a slicer for the months, I would ahve to transpose the table so that each month has its own row instead of column. This pose an issue however, if I want to also have a slicer for the year.

 

YearJan AmountFeb AmountMar Amount
2017064
201777863
2017065
2017064
20178764
20178985
2017688
201765787
2017784
20177066
2017456
2018846
20184594
2018677
20187686
2018897
201869786
201865796
20187866
20186566
2018796
2018896
20185606
201878866575

 

Is there a way I could query or format the data so that I can have functional slicers for both month and year simultaneously?

 

Thank you and all the best!

1 ACCEPTED SOLUTION
jdbuchanan71
Super User
Super User

Hello @MiekeV 

If you apply a couple steps to your query you can get what you are looking for.

1. Unpivot value columns

2. Remove "Amount" from the month name

3. Add a Month-Year column

MonthYear.jpg

I have attached my sample file for you to take a look at.

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

I think, best is you transpose it in power bi using unpivot. Else you use union/summarize and create a new table merging all month in one.

jdbuchanan71
Super User
Super User

Hello @MiekeV 

If you apply a couple steps to your query you can get what you are looking for.

1. Unpivot value columns

2. Remove "Amount" from the month name

3. Add a Month-Year column

MonthYear.jpg

I have attached my sample file for you to take a look at.

Sorry it took a while to get back to this! The "unpivot" function worked perfectly!

2 new columns were created, one for the month and the other with the values.

 

Thank you!

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.