Forum Discussion

eunji888888's avatar
eunji888888
Frequent Visitor
1 year ago

Calculated measure for filtering specific name without making many measures

I have below measure and everything look good, but i need to do the filter in the visual part for specific channel description to have the correct number. How could i fix it? i know i can filter specific channel but i have 6 specific channel which need to make 6 measures:

 

StdPrice814(TD) =
VAR EANValue = SELECTEDVALUE(' CustGroup4 Material'[EAN])
VAR ChannelValue = SELECTEDVALUE('CustGroup4 Material'[channel description])
VAR TradeDiscountPrice =
CALCULATE(
MAXX(
FILTER(
'CustGroup4 Material',
RIGHT('CustGroup4 Material'[Description], 1) = "%" &&
' CustGroup4 Material'[channel description] = ChannelValue&&
'CustGroup4 Material'[EAN] = EANValue
),
-'CustGroup4 Material'[StdPrice]
),
'CustGroup4 Material'[Promotion yes/no] = "Trade discount"
)

RETURN IF(ISBLANK(TradeDiscountPrice), BLANK(), TradeDiscountPrice)

 

5 Replies

  • Hello eunji888888 

    If you want to dynamically filter by channel without modifying the measure each time, you can add a slicer on channel description in your report. Then, use dax

    StdPrice814(TD) =

    VAR EANValue = SELECTEDVALUE('CustGroup4 Material'[EAN])

     

    VAR TradeDiscountPrice =

    CALCULATE(

        MAXX(

            FILTER(

                'CustGroup4 Material',

                RIGHT('CustGroup4 Material'[Description], 1) = "%" &&

                'CustGroup4 Material'[EAN] = EANValue

            ),

            -'CustGroup4 Material'[StdPrice]

        ),

        'CustGroup4 Material'[Promotion yes/no] = "Trade discount"

    )

     

    RETURN IF(ISBLANK(TradeDiscountPrice), BLANK(), TradeDiscountPrice)

    Thanks,
    Pankaj

    If this solution helps, please accept it and give a kudos, it would be greatly appreciated.

    • v-aatheeque's avatar
      v-aatheeque
      Community Support

      Hi eunji888888 ,
      Thanks for reaching out of Microsoft Fabric Community Forum.
      pankajnamekar25  Thanks for your Prompt response. In addition to the above DAX query add the below query after the "Trade discount"

      'CustGroup4 Material'[channel description] = ChannelValue  -- Add this filter dynamically

      You can also use the "Filters" pane to filter the visual by channel descriptions, and the measure will return the correct result based on the selected channel.

      This way you only need one measure and the filtering will be dynamic according to the visual's context, saving you from creating multiple measures for each channel.

      Hope this helps!

      Regards,
      v-aatheeque

      If this post was helpful, please consider marking Accept as solution to assist other members in finding it more easily.

      If you continue to face issues, feel free to reach out to us for further assistance!

       




  • v-sdhruv's avatar
    v-sdhruv
    Community Support

    Hi eunji888888 ,
    I wanted to check if you had the opportunity to review the suggestions provided?
    If the response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
    Please feel free to contact us if you have any further questions.
    Thank you

  • v-sdhruv's avatar
    v-sdhruv
    Community Support

    Hi @eunji888888 ,
    I wanted to check if you had the opportunity to review the suggestions provided?
    If the response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
    Please feel free to contact us if you have any further questions.
    Thank you

  • v-sdhruv's avatar
    v-sdhruv
    Community Support

    Hi @eunji888888 ,
    I wanted to check if you had the opportunity to review the suggestions provided?
    If the response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
    Please feel free to contact us if you have any further questions.
    Thank you