Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
1 year ago
Solved

Measure that takes in only specified filter context

Hi,

 

I need some help in creating a measure that would always show the total_weights based on the two active filters selected, i.e., mpId and riskProfile. See snapshot below for context. Currently, my total_weights measure is showing the right number (i.e., 70% based on my snapshot below) when both active filters are applied. However, the measure value is refreshed when I select a row in the table visual (e.g., The measure is updated as 10% if I select acId = 10921081 from the table visual). Is there a way to create a measure that takes in only the 2 active filters (mpId and riskProfile) and ignores the rest? 

total_weights =
CALCULATE
(
    SUM(mp_mix[percent]),
    ALLSELECTED(mp_mix)
)
  • Anonymous 

    First of all Percentage is a Non aditive measure. It cannot be summed up. It should be calculated inside in a measure itself.

    Now, the eaisest option is which sjoerdvn  mentioned.--> Turned off the Edit interaction.

    In dax, You need to igonore the filters from acid column .
    Below code can work for you.

    total weight = 
    CALCULATE(
        SUM( 'Table'[Percent] ),
    ALLEXCEPT('Table','Table'[Cateory],'Table'[RiskProfile])
    )

     

    Below screenshot

    Attaching the pbix file for your reference.

     

    Hope it helps

     

    Regards

    sanalytics

     

4 Replies

  • Anonymous  ,If you want to remove all filters except for mpId and riskProfile, you can use the ALL function combined with KEEPFILTERS to keep only the desired filters:

    DAX
    total_weights =
    CALCULATE(
    SUM(mp_mix[percent]),
    ALL(mp_mix),
    KEEPFILTERS(mp_mix[mpId]),
    KEEPFILTERS(mp_mix[riskProfile])
    )

     

    • sanalytics's avatar
      sanalytics
      Icon for Super User rankSuper User

      Anonymous 

      First of all Percentage is a Non aditive measure. It cannot be summed up. It should be calculated inside in a measure itself.

      Now, the eaisest option is which sjoerdvn  mentioned.--> Turned off the Edit interaction.

      In dax, You need to igonore the filters from acid column .
      Below code can work for you.

      total weight = 
      CALCULATE(
          SUM( 'Table'[Percent] ),
      ALLEXCEPT('Table','Table'[Cateory],'Table'[RiskProfile])
      )

       

      Below screenshot

      Attaching the pbix file for your reference.

       

      Hope it helps

       

      Regards

      sanalytics

       

      • Anonymous's avatar
        Anonymous
        Not applicable

        Thanks, the suggested DAX expression works for me. Toggling with the interactions wouldn't work in this case since I need that measure for other downstream calculations.