cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Helper II
Helper II

Variable in column name in summarize table

I am creating a calculated table by summarizing date, country, branch and sales amount from Table Sales

 

Branch_Sales_calc =

var branch =  'Parameter'[Branch]  -- value is from query parameter

 
RETURN SUMMARIZE(
'Sales','Sales'[Date], 'Sales'[Country], "BranchName",SUMX(FILTER('Sales','Sales'[Branch]=branch) ,'Sales'[Amount]))
)

If I change
the column name "BranchName" to variable branch I get the error - Function SUMMARIZE expects a column name as argument number 4
 
Is it possible to have column name based on query parameter or any dynamic value?
 
1 ACCEPTED SOLUTION

@MikeKK Currently it is not supported to change the column name dynamically with the parameter.

 

As a workaround, I suggest using fixed "Sales" or "Total Sales" as the name of this column to indicate what this column's data describes. Then format the visual's title conditionally with the field 'Parameter'[Branch] to let users know which branch this data represents for.

120203.jpg

 

Kindly let me know if this helps.

 

Community Support Team _ Jing Zhang
If this post helps, please consider Accept it as the solution to help other members find it.

View solution in original post

7 REPLIES 7
Super User IV
Super User IV

@MikeKK , I doubt you can use a slicer value or parameter in a new table creation

 

also try changing var like and try

var branch =  max('Parameter'[Branch] )



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

I have tried, it does not work. 

@MikeKK Currently it is not supported to change the column name dynamically with the parameter.

 

As a workaround, I suggest using fixed "Sales" or "Total Sales" as the name of this column to indicate what this column's data describes. Then format the visual's title conditionally with the field 'Parameter'[Branch] to let users know which branch this data represents for.

120203.jpg

 

Kindly let me know if this helps.

 

Community Support Team _ Jing Zhang
If this post helps, please consider Accept it as the solution to help other members find it.

View solution in original post

Super User IV
Super User IV

Oh.  You can't use a variable where "BranchName" is.  Why is that needed?  Why not use a fixed name that reflects what is in that column like "TotalSales"?  If needed, you could add another column to your table that has the branch name on every row.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


The report I want to build needs a column name on matrix table that based on user selection. That is why I need a dynamic column name

Super User IV
Super User IV

Is Parameter a text value?  Or is it a 1-row/1-column table?  If a table, you need to aggregate it with MIN('Parameter'[branch]) for example.

 

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Yes, it is a 1-row/1-column table, text value, I have tried aggregation MIN butstill get the same error - Function SUMMARIZE expects a column name as argument number 4.

 

 

Helpful resources

Announcements
secondImage

Experience what’s next for Power BI

Join us for an in-depth look at the new Power BI features and capabilities at the free Microsoft Business Applications Launch Event.

secondImage

Power BI Women

Join our monthly meetings and learning sessions.

secondImage

Congratulations!

We are excited to announce the Power BI Super Users!

secondImage

The largest Power BI virtual conference

100+ sessions, 100+ speakers, Product managers, MVPs, and experts. All about Power BI. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors