Forum Discussion
SwathiGanesh
3 years agoFrequent 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 un...
Sahir_Maharaj
Super User
3 years agoHello 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.
SwathiGanesh
3 years agoFrequent Visitor
How to switch when two columns are selected and I need to summarize into one table
- Sahir_Maharaj3 years ago
Super User
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.
- Håkon3 years ago
Advocate II
Jeg setter stor pris på hjelpen!