Forum Discussion
Creating a line chart with a dynamic total line
- 5 years ago
Anonymous solution attached.
edhans , not sure if not having that function I'm missing anything. Never had a need for it but it can be surely handy.
Check my latest blog post Comparing Selected Client With Other Top N Clients | PeryTUS I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!
⚡Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.⚡
Here is one way to do at Anonymous
count =
VAR varSelectedValue = SELECTEDVALUE('Table (2)'[Column1])
VAR varSelectedValueTable = { varSelectedValue }
VAR varFilteredTable =
FILTER(
'Table',
'Table'[Column1] in varSelectedValueTable
)
VAR varTotalCount =
CALCULATE(
COUNTROWS('Table'),
KEEPFILTERS('Table'[Column1] in varSelectedValueTable)
)
VAR Result = COALESCE(varTotalCount, 0)
RETURN
Result
What this does is it takes the Selected Value from your slicer table (disconnected) and turns it back into a table - that is what the {} syntax does. I then added a bit more logic so it returns 0 for those values not selected, not a blank.
Then I count the rows in the main table where the values in column 1 of that table exist in the table created from the slicer selection.
I only get a count if one value is selected in the slicer. If multiple values are selected, the count is 0, which is undesirable. I need to be able to select mutiple values at the same time and get the total count for all of them.
- edhans5 years agoCommunity Champion
Ok, that would have been really helpful to know in the original post. Unfortunately I didn't save my work so I will have to circle back to this later.