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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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