Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

replace value for a certain slicer selection

Dear all,

 

I have the following situation:

I have item 1 of product class A and want to compare it to other items.

I have a slicer to select product classes for the compare items with the options A, B, C, All classes, automatic.

In the case of "Automatic", the filter should automatically chose the product class of item 1 for the compare items, in this case product class A

So far, I have a measure 

product measure = CONCATENATEX(VALUES('Produkt_Options'[Produkt]);'Produkt_Options'[Produkt];",") 
to join all options together 
e.g. when I select A and B in the slicer, I get A,B
when I choose Automatic, I get Automatic,   but I would like to get A
How can I  define what I want for the otpion automatic?
 
Kind regards
Susanne
  • Hi Anonymous ,

     

    Please create a measure as below to work on it.

    Measure = 
    VAR se =
        SELECTEDVALUE ( 'Table'[Option] )
    RETURN
        IF (
            NOT ( ISFILTERED ( 'Table'[Option] ) ),
            BLANK (),
            IF ( se = "Automatic", "A", CONCATENATEX ( 'Table', 'Table'[Option], "," ) )
        )
    

     

    Pbix as attached.

     

     

2 Replies

  • kentyler's avatar
    kentyler
    Solution Sage

    You can use an expression for concantenatex

    CONCATENATEX(Employees, [FirstName] & “ “ & [LastName], “,”)

    so use ....IF('Produkt_Options'[Produkt]="Automatic",[measure to look up product class of first item],'Produkt_Options'[Produkt])

     

    I'm a personal Power Bi Trainer I learn something every time I answer a question

    The Golden Rules for Power BI

    1. Use a Calendar table. A custom Date tables is preferable to using the automatic date/time handling capabilities of Power BI. https://www.youtube.com/watch?v=FxiAYGbCfAQ
    2. Build your data model as a Star Schema. Creating a star schema in Power BI is the best practice to improve performance and more importantly, to ensure accurate results! https://www.youtube.com/watch?v=1Kilya6aUQw
    3. Use a small set up sample data when developing. When building your measures and calculated columns always use a small amount of sample data so that it will be easier to confirm that you are getting the right numbers.
    4. Store all your intermediate calculations in VARs when you’re writing measures. You can return these intermediate VARs instead of your final result  to check on your steps along the way.
  • v-frfei-msft's avatar
    v-frfei-msft
    Community Support

    Hi Anonymous ,

     

    Please create a measure as below to work on it.

    Measure = 
    VAR se =
        SELECTEDVALUE ( 'Table'[Option] )
    RETURN
        IF (
            NOT ( ISFILTERED ( 'Table'[Option] ) ),
            BLANK (),
            IF ( se = "Automatic", "A", CONCATENATEX ( 'Table', 'Table'[Option], "," ) )
        )
    

     

    Pbix as attached.