Forum Discussion
Counting column items based on column selection
- Anonymous2 years ago
HI SBePicas,
I'd like to suggest you create a new table with three field names and use it as source of slicer.
NewTable = DATATABLE ( "ColName", STRING, { { "Col1" }, { "Col2" }, { "Col3" } } )After these steps, you can create a measure formula with switch function to check current selected value and redirect to different calculation expressions.
DC based on selection = VAR selected = SELECTEDVALUE ( NewTable[ColName] ) RETURN SWITCH ( selected, "Col1", COUNTROWS ( VALUES ( Table1[Col1] ) ), "Col2", COUNTROWS ( VALUES ( Table1[Col2] ) ), "Col3", COUNTROWS ( VALUES ( Table1[Col3] ) ), COUNTROWS ( VALUES ( Table1[Col1] ) ) )Regards,
Xiaoxin Sheng
Sorry, still learning the proper terminology.
I have one table with 3 columns. Each field (column) is dragged into the report editor and thus I have three visuals in the report editor.
HI SBePicas,
I'd like to suggest you create a new table with three field names and use it as source of slicer.
NewTable =
DATATABLE ( "ColName", STRING, { { "Col1" }, { "Col2" }, { "Col3" } } )
After these steps, you can create a measure formula with switch function to check current selected value and redirect to different calculation expressions.
DC based on selection =
VAR selected =
SELECTEDVALUE ( NewTable[ColName] )
RETURN
SWITCH (
selected,
"Col1", COUNTROWS ( VALUES ( Table1[Col1] ) ),
"Col2", COUNTROWS ( VALUES ( Table1[Col2] ) ),
"Col3", COUNTROWS ( VALUES ( Table1[Col3] ) ),
COUNTROWS ( VALUES ( Table1[Col1] ) )
)
Regards,
Xiaoxin Sheng