Forum Discussion

lilyyan's avatar
lilyyan
Frequent Visitor
9 years ago
Solved

What's the difference between ALL vs. ALLSELECTED, with formula filter as table vs. column

The original file Understanding Your Customers is downloaded from http://enterprisedna.co/power-bi-resources.

 

When calculating the total sales with different filters ALL and ALLSELECTED, with formula filter as table vs. column, the different results totally confused me. 

 

Here's the different results:

1. For Cumulative Caculation, ALL( Dates[Date]), ALLSELECTED(Dates[Date]), ALL(Dates) are same ignoring report filter, different with ALLSELECTED( Dates)

Cumulative Sales =

CALCULATE(

[Total Sales] ,

FILTER(

ALL( Dates[Date]),

Dates[Date] <= MAX( Dates[Date])))

 

Cumulative Sales 2 =

CALCULATE(

[Total Sales] ,

FILTER(

ALLSELECTED(Dates[Date]),

Dates[Date] <= MAX( Dates[Date])))

 

Cumulative Sales 3 =

CALCULATE(

[Total Sales],

FILTER(

ALL(Dates),

Dates[Date]<=MAX(Dates[Date])))

 

Cumulative Sales (Selected) =

CALCULATE( [Total Sales] ,

FILTER(

ALLSELECTED( Dates),

Dates[Date] <= MAX( Dates[Date])))

 

2. But for calculation of all dates, ALL(Dates[Date]), ALLSELECTED(Dates[Date]), ALLSELECTED(Dates) are same with report filter working, different with ALL( Dates)

 

Total Sales (all selected) =

CALCULATE( [Total Sales] , all( Dates[Date] ))

 

Total Sales (all Selected) 2=

CALCULATE( [Total Sales] , ALLSELECTED( Dates[Date] ))

 

Total Sales (all selected)3 =

CALCULATE( [Total Sales] , ALLSELECTED( Dates))

 

Total Sales (all) =

CALCULATE( [Total Sales] , ALL( Dates))

 

 

  • Anonymous's avatar
    Anonymous
    9 years ago

    Hi lilyyan,

     

    I think I found the reason, please take a look at below  test steps.

     

    Measure used to display the current row count.

    All(Table)/All(Column)/AllSelected(Table)/Allselected(Column) = COUNTROWS(ALL(Dates))&"-"&COUNTROWS(ALL(Dates[Date]))&"-"&COUNTROWS(ALLSELECTED(Dates))&"-"&COUNTROWS(ALLSELECTED(Dates[Date]))

     

     

    1. Calculate the real count by year filter and quarter filter.

     

    Result: allselected table work, allselected column not work.

     

    2. Test with date slicer.

     

    Result: allselected(table) and allselected(column) works.

     

    3. Test with date slicer and line chart.

     

    In summary, when you use allselected function, you should remember allselected(table) can works on all of its columns, but allselected(column) only works on the slicer with specify column as the source.

     

    Regards,

    Xiaoxin Sheng

7 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi lilyyan,

     

    Can you provide the pbix file to test? I'm not very clear for your measure "Total Sales".

     

    Regards,

    Xiaoxin Sheng

    • lilyyan's avatar
      lilyyan
      Frequent Visitor

      AnonymousSorry that I don't know how to attach the file here. It's downloaded as mentioned in post: Understanding Your Customers from http://enterprisedna.co/power-bi-resources. 

       

      The source data file as below, including one row named Total Revenue. And Total Sales = SUM(Sales[Total Revenue])

      :