Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
Randomlndex0
New Member

Output value from selected row, but other column in card

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.

1 ACCEPTED SOLUTION

@Randomlndex0 

 

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.

View solution in original post

3 REPLIES 3
daxer-almighty
Solution Sage
Solution Sage

[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).

@Randomlndex0 

 

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.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors