Forum Discussion
PATHCONTAINS and Multiple selected value
Hi Experts,
i have created below measure to calculate aggregated profit amount for locations at parent level (like Continent, Country, Province) which would be summation of children cities. Our Database stores data at city level only.
Parent Profit Amount :=
VAR c = SELECTEDVALUE ( DimLocation[LocationKey] )
RETURN
CALCULATE (
SUM ( FactAmount[Profit] ),
ALL ( DimLocation ),
PATHCONTAINS ( DimLocation[Path], c )
)
Now the issue is, how can i handle if there are multiple selected values ? Because here, SELECTEDVALUE () function expects a single distinct value and if its given multiple values it doesn't show anything. Suppose below data exists in Database:
| Country | LocationKey | City | Profit Amount |
| England | 10 | London | 25 |
| USA | 11 | London | 30 |
| Canada | 12 | London | 45 |
And i just want to show "City" and its "Profit Amount" in chart.
The above measure won't display anything for Location="London" because for "London" location SelectedValue() function gets 3 locationkey values "10,11,12". So in the chart London isn't shown at all.
Please help.
Regards,
Amar
8 Replies
- lbendlinSuper User
Here are some options:
- use MIN/MAX instead of SELECTEDVALUE
- use TOPN(1,FILTERS())
- make your slicer single select.
- amarsale85Helper II
Thank you for your reply.
Is there a way to take all multiple values and apply it to the measure in PathContains() function?
- lbendlinSuper User
yes, convert your path into a table variable and then use INTERSECT()
- PaulDBrownCommunity Champion
Apologies since I'm not familiar with the PATHCONTAINS function, but wouldn't this measure work?
Total by city = CALCULATE([Sum of Profit], ALLEXCEPT(table, table[city])) - randymarchenaFrequent Visitor
Hi, did you find a solution to your question?