Forum Discussion

MiekeV's avatar
MiekeV
Frequent Visitor
6 years ago
Solved

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!

  • 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

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

3 Replies

  • 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

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

    • MiekeV's avatar
      MiekeV
      Frequent Visitor

      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!

  • 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.