5 Replies - 200 Views - Last Post: 02 February 2022 - 09:59 AM

#1 DarenR   User is offline

  • D.I.C Lover

Reputation: 793
  • View blog
  • Posts: 5,094
  • Joined: 12-January 10

pivot table with dynamic headings

Posted 01 February 2022 - 08:28 AM

is there a way to make dynamic pivot tables where the columns can change?

examples:

student    grade    class    prof
1            a         x       yang




can also be
student location    prof   grade  method
1         l           yang   a      test



the data is stored in multiple tables and depending on the class can have different column names

Is This A Good Question/Topic? 0
  • +

Replies To: pivot table with dynamic headings

#2 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 16481
  • View blog
  • Posts: 65,329
  • Joined: 12-June 08

Re: pivot table with dynamic headings

Posted 01 February 2022 - 09:02 AM

Oooof... I don't think so. There's some chatter about 'dynamic' and pivot, but at some point they need to have the column names somewhere spelled out.

Unfortunately this maybe a case of making a pivot stored procedure for the sources.. or codifying the sources to minimal number of shared columns.
Was This Post Helpful? 0
  • +
  • -

#3 Sheepings   User is offline

  • D.I.C Lover
  • member icon

Reputation: 263
  • View blog
  • Posts: 1,395
  • Joined: 05-December 13

Re: pivot table with dynamic headings

Posted 01 February 2022 - 01:35 PM

No.

Assuming C# related?

Why not just have all the class properties reflect the table fields and set Attributes on your properties for table convenience in your class file?
Was This Post Helpful? 0
  • +
  • -

#4 DarenR   User is offline

  • D.I.C Lover

Reputation: 793
  • View blog
  • Posts: 5,094
  • Joined: 12-January 10

Re: pivot table with dynamic headings

Posted 02 February 2022 - 06:19 AM

it's for ssrs report

they decided to mix up all the data into different tables all with some matching id's

kinda a cluster
Was This Post Helpful? 0
  • +
  • -

#5 Sheepings   User is offline

  • D.I.C Lover
  • member icon

Reputation: 263
  • View blog
  • Posts: 1,395
  • Joined: 05-December 13

Re: pivot table with dynamic headings

Posted 02 February 2022 - 09:44 AM

' All with some 'matching id's '? What are the id's for?

Do you mean like this..

If you had a table named supplies :
id                   item         
1                    bread         
2                    teabags       
3                    Coffee      


You could use union, innerjoin etc if the data truly is segregated and use a new table with an id to reference the old table. Eg.
id             idofsupplies                      item                 moreitems                                  MoreCollumnsHere
1                    3                           Sugar                Plastic Spoons
2                    1                           Butter               Plastic Knifes

etc.... why on earth would you want to move the structure?

Frankly DarenR, their bad call in mixing up the data. What you are asking defeats the purpose of using a database structure.

If you're using C# with this? You would use interfaces as contracts to work with the new data model classes. If not, I doubt you will get many other suggestions.

This post has been edited by Sheepings: 02 February 2022 - 02:11 PM

Was This Post Helpful? 0
  • +
  • -

#6 Sheepings   User is offline

  • D.I.C Lover
  • member icon

Reputation: 263
  • View blog
  • Posts: 1,395
  • Joined: 05-December 13

Re: pivot table with dynamic headings

Posted 02 February 2022 - 09:59 AM

To pivot the structure.. well wouldn't this then pivot for existing data sending existing data out of whack, or does it not matter where the data resides? :blink:
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1