Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Product Name = IF(COUNTROWS(DISTINCT(ALLSELECTED('Production Product'[StandardCost])))<COUNTROWS(DISTINCT(ALL('Production Product'[StandardCost]))),
IF(COUNTROWS(DISTINCT(ALLSELECTED('Production Product'[StandardCost]))) >= 2 ,
"Multiple Selected",
/* value of 'Production Product'[Name] from the selected 'Production Product'[StandardCost] row*/
),
"All Selected"
)
As the Subject says, I want to Output a Value into a Card.
The Selection of the StandardCost takes place in a Line chart and the output : "All Selected" and "Multiple Selected" works without Issue, but I can't seem to find a way to output the Name String from the Name column.
I am using the AdventureWorks2012 Database from Microsoft if that helps in any way.
Solved! Go to Solution.
Since you have not given us any model and data to work with, it's almost obvious that formulas can have typos in them. We can't test them, of course. But that's not even a minor issue since you can easily correct the typos.
I gave you a hint in the SWITCH to use CONCATENATEX to output all the visible names. Please consult the definition of SELECTEDVALUE to understand when it returns BLANK and then use CONCATENATEX to output all the visible values.
[Product Name] =
// You should never calculate anything more than once...
// If you do, you are slowing things down.
var SelectedCostsCount =
COUNTROWS(
ALLSELECTED ( 'Production Product'[StandardCost] )
)
var AllCostsCount =
COUNTROWS(
ALL ( 'Production Product'[StandardCost] )
)
var Result =
switch( true,
SelectedCostCount = AllCostCount,
"All Selected",
SelectedCostCount > 1,
"Multiple Selected",
SelectedCostCount = 1,
// I assume that if one cost has been selected,
// it means that only one product will be visible
// in the Production Product table. If this is
// not the case, you can use CONCATENATEX to output
// all the names in a comma-separated format.
SELECTEDVALUE( 'Production Product'[Name] ),
// guard clause
SelectedCostCount = 0, "This should not happen"
)
return
Result
1. Thanks for the tip with the variables.
2. Your variable names don't match, since you wrote SelectedCostsCount and AllCostsCount in the declaration.
3. Sadly it doesn't output the Product Name and returns as (Blank).
Since you have not given us any model and data to work with, it's almost obvious that formulas can have typos in them. We can't test them, of course. But that's not even a minor issue since you can easily correct the typos.
I gave you a hint in the SWITCH to use CONCATENATEX to output all the visible names. Please consult the definition of SELECTEDVALUE to understand when it returns BLANK and then use CONCATENATEX to output all the visible values.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
47 | |
26 | |
19 | |
14 | |
10 |
User | Count |
---|---|
58 | |
50 | |
44 | |
19 | |
18 |