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

Using slicer for sum of columns

Suppose I have the following data:

 

NameCountryJanuaryFebruaryMarchAprilMayJuneJulyAugustSeptemberOctoberNovemberDecember
AlexUSA140741213981310018683135
AndrewUSA57246732213729805492534
DiegoSpain8410052328611697477267385
GeorgeCanada30958944854197385115919
JohnAustralia4790165580879871479375
LauraSpain662476827192596468781684
MaryCanada144964449149962676253334
SantiagoSpain55973282718831278955775

 

I want to have a slicer with the months of the year, allowing single or multiple segmentation at once. With that I'd like to have a table (or any graphic) that shows the sum of the values for each country, depending on the months selected in the slicer.

 

For example:

If only January is selected as a filter we would obtain this count: USA - 71, Spain - 205, Canada - 44, Australia - 47. However, if we select from January, February and March in the slicer, we would obtain: USA - 236, Spain - 586, Canada - 341, Australia - 153.

 

I need help on how to handle this problem, since I don't know how to turn "Months" into a slicer.

 

Thanks in advance.

3 ACCEPTED SOLUTIONS
selimovd
Super User
Super User

Hey @Anonymous ,

 

you should unpivot the month columns. You can do that like this:

Unpivot.gif

 

 

Then you can rename the "Attribute" column to "Date", replace the values with real dates and then you can slice by date in the report.

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

View solution in original post

parry2k
Super User
Super User

@Anonymous understood, but as a best practice and a scalable solution, it is always good to have unpivoted data. There is always create a better model or write a complex DAX to achieve the business goal. You decide what to pick. So better to revisit your solution by revisiting that this needs to be unpivoted. All the best. 

 

Check my latest blog post Comparing Selected Client With Other Top N Clients | PeryTUS  I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

V-pazhen-msft
Community Support
Community Support

@Anonymous 

Dax calculation is based on rows not column, the best solution for is to transform the table making the month into rows then you can create a slicer to filter to interact. If you are worrying about later report creation. You can just duplicate the table then use the new table for this sum calculation.

 

 

Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
V-pazhen-msft
Community Support
Community Support

@Anonymous 

Dax calculation is based on rows not column, the best solution for is to transform the table making the month into rows then you can create a slicer to filter to interact. If you are worrying about later report creation. You can just duplicate the table then use the new table for this sum calculation.

 

 

Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.

parry2k
Super User
Super User

@Anonymous understood, but as a best practice and a scalable solution, it is always good to have unpivoted data. There is always create a better model or write a complex DAX to achieve the business goal. You decide what to pick. So better to revisit your solution by revisiting that this needs to be unpivoted. All the best. 

 

Check my latest blog post Comparing Selected Client With Other Top N Clients | PeryTUS  I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

selimovd
Super User
Super User

Hey @Anonymous ,

 

you should unpivot the month columns. You can do that like this:

Unpivot.gif

 

 

Then you can rename the "Attribute" column to "Date", replace the values with real dates and then you can slice by date in the report.

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 
Anonymous
Not applicable

Hey @selimovd  thanks for the help.

 

I wonder if there is any other alternative to solve this. Since this is a very simplified example of the real data that I'm handling, and the dashboard has many others graphics and variables, I don't know if by "unpivoting" my data, managing the information of the other columns would be more difficult.

parry2k
Super User
Super User

@Anonymous you need to unpivot your data in PQ

 

- transform data
- select name and country columns in the table
- right-click, unpivot other columns it will add two columns, attribute, and value, rename these as per your requirement
- close and apply

Now you can slice the data by months.

 

Check my latest blog post Comparing Selected Client With Other Top N Clients | PeryTUS  I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

@parry2k thanks for the response.

 

Question: this is a simplified example of the real data that I'm handling, and the dashboards has many others graphics and variables. If I unpivot my data wouldn't that make more difficult the ellaboration of my dashboard? Is there any other alternative to the stated problem?

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.