Forum Discussion
ALLSELECTED Duplicating Table Output
- 6 years ago
hi steveplatz
You could just adjust it as below:
Step1:
Adjust the formula as below:
New MaxSelectedSales = CALCULATE(MAX(FactSales[Sales]),ALLSELECTED(FactSales),VALUES(DimMarket[MarketName]))Step2:change the cross filter direction from "Single" to "Both"Result:
and here is sample pbix file, please try it.
Regards,
Lin
This what my measure ended up like
Max Sales per Market =
VAR cur_Market =
SELECTEDVALUE ( Sales[MarketId] )
VAR total_sales_per_market =
CALCULATE ( MAX ( Sales[Sales] ), ALL ( Sales ), Sales[MarketId] = cur_Market )
RETURN
total_sales_per_market
in a problem like this the first step is to get the value you want to filter by out of the current filter context-- in this case SELECTEDVALUE() does that-- and store it in a variable
the next step is to do your calculation-- inside the CALCULATE() I use ALL() to remove any filters on the Sales table coming from the external filter context (like the one from the table visual that gets the values for a specific row) and use the saved variable as a filter to get only the rows I want the MAX of
Power BI is easy to learn, but it has hard parts.
|
kentyler Thanks for the detailed response. That makes sense and works if I'm looking for the max per market, but what I'm trying to accomplish is to get the MAX value of all selected records, taking any outside filters into account. This is a simplified example with only the IsCurrent and Market filters, but there could be much more.
Do you know how I would accomplish that?
- kentyler6 years agoSolution Sage
You can change to ALLSELECTED
Max Sales per Market = VAR cur_Market = SELECTEDVALUE(Sales[MarketId])VAR total_sales_per_market = CALCULATE(max(Sales[Sales]),ALLSELECTED(Sales),Sales[MarketId]=cur_Market) return total_sales_per_marketThat seems to take both a store slicer and an iscurrent slicer into account- steveplatz6 years agoFrequent Visitor
This works when filtered to a specific market, but not when all markets are displayed. I changed the MAX for "Market 2" to be different than Market 1 and get this result:
What I'd like to see is 140 for every cell in MaxSelectedSales2.
- kentyler6 years agoSolution Sage
Maybe you need to remove the filter on just one market in line 3.