Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Calcuate DAX help

I have two measures 

Example:

One is calculate(sum(value), filter(Table,table.source="a")

Another measure is calculate (sum(value),filter( table.table.source="b")

 

these measures are displaying in tabluar report.

 

state - Measure 1 ,Measure2

 

Also ,at the same time . The user  asking a slicer ( tablea.date),that should required in the report which should filter only Measure2 values ,not measure1 value.

 

How to avoid slicer - filter values that should not pass to measure1 values? What is the best DAX for calucating the measure 1 ?

 

 

 

  • Hi Anonymous ,

     

    Using all will clear all context filtering conditions.

    Choosing to use all or allexcept depends on the results you expect.

    There is only one state where you can choose to use all.

    Measure = CALCULATE(SUM('Table'[value]),FILTER(ALL('Table'),'Table'[source]="a"))

    There are several states that can choose to use allexcept

    Measure = CALCULATE(SUM('Table'[value]),FILTER(ALLEXCEPT('Table','Table'[state]),'Table'[source]="a"))

     

    Best Regards,
    Liang
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

6 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

    Anonymous - You will need to use ALLEXCEPT in order to exclude certain filters from affecting your measure. Would be easier to be specific with sample data and expected output:

     

    Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

    The most important parts are:
    1. Sample data as text, use the table tool in the editing bar
    2. Expected output from sample data
    3. Explanation in words of how to get from 1. to 2.

  • Anonymous's avatar
    Anonymous
    Not applicable

    allexecpt not working.

    Measure1 -

     

    Sample

    SourceProcess DateValueState
    ABlank2001
    B03/30/20203001
    B04/30/20204001

     

    Report: when slicer applied on Process Date (exmple value 04/30/2020) ,the report should show like below

    the Source A values should not filtered out based on process date

     

    SourcestateValue
    A0120
    B0140

     

    Source 

    • V-lianl-msft's avatar
      V-lianl-msft
      Community Support

      Hi Anonymous ,

       

      Using all will clear all context filtering conditions.

      Choosing to use all or allexcept depends on the results you expect.

      There is only one state where you can choose to use all.

      Measure = CALCULATE(SUM('Table'[value]),FILTER(ALL('Table'),'Table'[source]="a"))

      There are several states that can choose to use allexcept

      Measure = CALCULATE(SUM('Table'[value]),FILTER(ALLEXCEPT('Table','Table'[state]),'Table'[source]="a"))

       

      Best Regards,
      Liang
      If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

    • V-lianl-msft's avatar
      V-lianl-msft
      Community Support

      Hi Anonymous ,

       

      Is this problem sloved?
      If not, please let me know.

       

      Best Regards,
      Liang
      If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • FarhanAhmed's avatar
    FarhanAhmed
    Community Champion

    Try use ALL(Table) with your measure 1. This will exclude any external filter applied on measure.

    If you want certain external filters to be applied on measure then use ALLEXCEPT (Table, [filtercolumn1],[filtercolumn2]... etc)....

     

    calculate(sum(value), filter(All(Table),table.source="a")