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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
SwathiGanesh
Frequent Visitor

Need syntax help to summarize only the selected column

I have three columns in a table and we are using parameters to select the required column to the table.
Based on the selected column, I need to summarize and do some calculation.
I am stuck and unable to find how to make “VAR SUMMERISE” to work, this variable should summerize the selected columns only. I am using this to find the denominator.
It works fine when all three columns are selected, but I need to summerize based on the selected column
Parameter are [column names]: We have a slicer on the page

 

 

🔲Partnername

☑️partnerTYPE

☑️partnercountry
I need a syntax to summarize just the selected columns

Uniques =
VAR sumfc = SUM(salary)
VAR SUMMARISE = SUMMARIZE(Partnername, Partnercountry, partnerTYPE, "Average", sumfc)
RETURN
    IF(
        OR(
            ISINSCOPE('Partnername'),
            OR(ISINSCOPE('Partnercountry'), ISINSCOPE(partnerTYPE))
        ),
        SUM(salary),
        DIVIDE(sumfc, COUNTROWS(SUMMARISE))
    )
5 REPLIES 5
SwathiGanesh
Frequent Visitor

@Sahir_Maharaj  Thanks for replying, but I am trying both the solution and still getting this error
"The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value."

Sahir_Maharaj
Super User
Super User

Hello @SwathiGanesh,

 

You can use the SWITCH function to check which column is selected.

 

Uniques =
VAR SelectedColumn = SELECTEDVALUE('Table'[Parameter])
VAR sumfc = SUM('Table'[Salary])
VAR SUMMARISE =
    SWITCH(
        SelectedColumn,
        "Partnername", SUMMARIZE('Table', 'Table'[Partnername], "Average", sumfc),
        "partnerTYPE", SUMMARIZE('Table', 'Table'[partnerTYPE], "Average", sumfc),
        "partnercountry", SUMMARIZE('Table', 'Table'[partnercountry], "Average", sumfc)
    )
RETURN
    IF(
        OR(
            ISINSCOPE('Table'[Partnername]),
            OR(ISINSCOPE('Table'[partnerTYPE]), ISINSCOPE('Table'[partnercountry]))
        ),
        SUM('Table'[Salary]),
        DIVIDE(sumfc, COUNTROWS(SUMMARISE))
    )

 

Should you require further assistance, please do not hesitate to reach out.


Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution? (Yes, its FREE!)
➤ Lets connect on LinkedIn: Join my network of 15K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ About: https://sahirmaharaj.com/about.html
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning

How to switch when two columns are selected and I need to summarize into one table

@SwathiGanesh, you can use the UNION function to combine the data from both columns into a single table.

 

UnionTable =
UNION(
    SELECTCOLUMNS(Table1, "Column1", [Column1], "Column2", BLANK()),
    SELECTCOLUMNS(Table2, "Column1", BLANK(), "Column2", [Column2])
)

 

The SELECTCOLUMNS function is used to select the columns from each table that you want to include in the UnionTable.


Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution? (Yes, its FREE!)
➤ Lets connect on LinkedIn: Join my network of 15K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ About: https://sahirmaharaj.com/about.html
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning

Jeg setter stor pris på hjelpen!

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.