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

Dynamic measure to apply to multiple columns

Hi all, 

 

I have tralled through the forum for hours now and cant quite find a solution so I am really hoping for some help with this one. 

 

I have a  table that when simplified looks a bit like the one below.

 

I need a solution as I have 164 columns with data like this (survey data) and my current solution requires a measure for each one - its not quite sustainable. 

 

What I would like to do is create a process where the same measure is applied depending on what column is selected in a slicer. So for example if I could sum the data depending on column selected without having to create an individual measure for each column to call. 

 

CategoryIDColumn 1Column 2Column 3Column 4Column 5Column 6Column 7Column 8Column 9Column 10
ABC12254444423
ABC22554424424
ABC31525224415
ABC45523213352
ABC56613153366
ABC66653565565
DEF74662665545
DEF84662643265
DEF93341443265
DEF106245443265
DEF111236353265
GHI124166615165
GHI136514145564
GHI144644462646
GHI154663642645
GHI165446441454

 

Help on this would be GREATLY appreciated!

 

5 REPLIES 5
Ashish_Mathur
Super User
Super User

Hi,

In the Query Editor, right click on the first 2 columns and select "Unpivot other columns".  Rename the Attribute column, if you wish to.  Now drag the Attribute (or remaned) column to the slicer and build your visual.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

@Ashish_Mathur 

Thanks for this, I can't unpivot this dataset unfortunately, the dataset is too big and needs to be structured this way. I am looking for a solution that doesnt require unpivoting if possible. 

 

Thanks so much

You are welcome.  That will not be possible.  "Data being big" cannot be a reason to not "Unpivot".


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Thanks, really hoping that I wont have to unpivot. Still waiting for the query to run and thats just testing it on only a quarter of a years data; I need to merge and unpivot data for 2 years. 

 

Wondering if I could get help with M, wondering if something like mentioned here could be fashioned for this: https://blog.crossjoin.co.uk/2016/03/07/dynamic-column-selection-in-custom-columns-in-power-bipower-...

 

 

ChandeepChhabra
Impactful Individual
Impactful Individual

@Anonymous 

The Ideal way to go about this would be to unpivot the columns in Power Query. For the given table

  1. Select the first 2 columns (category & id)
  2. Right click and choose unpivot other columns

 

Then you should write a single measure which will work as expected

=SUM(Data[Col Name])

 

Capture.PNG

Please find the Power BI file attached here

 

Thanks

 

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.