Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
jmkvalsund
Helper II
Helper II

Dynamic number and names of columns in dataset

I'm trying to convert a solution previously using ASP.NET as report viewer, into using paginated reports in Power BI instead.
So far so good, Ive managed to convert many of my reports, since the data is provided using stored procedures on a SQL Server with simple inputs like dates and salesgroups.
However, some of the procedures delivers dynamically output, i.e. where sales are shown by seller as columns and products as rows. Then there will be different numbers and names of columns depending on which salesgroup being selected.
How do I map a datadset to a table or tablix when the columns are different depending on the input parameter?
Is there a way to count columns in the dataset and format the table that way? (Thats how I've done it in ASP.NET, the two first columns being fixed like salesdate and productname, the last total sales and those between sales by each seller) 

Regards,
John Martin

1 ACCEPTED SOLUTION
d_gosbell
Super User
Super User


@jmkvalsund wrote:

How do I map a datadset to a table or tablix when the columns are different depending on the input parameter?


You don't. Report Builder cannot handle queries with a variable amount of columns.

 

So instead of doing the pivot operation in your stored proc you should just return the unpivoted data and then put the column you want as columns on the columns axis of the tablix.

View solution in original post

1 REPLY 1
d_gosbell
Super User
Super User


@jmkvalsund wrote:

How do I map a datadset to a table or tablix when the columns are different depending on the input parameter?


You don't. Report Builder cannot handle queries with a variable amount of columns.

 

So instead of doing the pivot operation in your stored proc you should just return the unpivoted data and then put the column you want as columns on the columns axis of the tablix.

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Power BI Header Change

Power BI Header Update

Read about the exciting updates for the Power BI forum.