locked
ALLSELECTED AND VALUES RRS feed

  • Question

  • Hello. What is allselected and values doing below? 

    Avg Sales Growth:=CALCULATE (
        [Sales Growth] ,
        ALLSELECTED (),
        VALUES (DimDate[CalendarYear])
    )

    Thursday, September 22, 2016 7:23 PM

Answers

  • Hi AlexMartini,

    ALLSELECTED Function returns the context of the query without any column and row filters.
    In order to understand the behavior of ALLSELECTED, we use a very simple data model as follows.


    Create measure

    sum allselect:=CALCULATE(SUM(Custom7[Column1]),ALLSELECTED())

    I create a pivot table with ID as rows,  the “sum of column” and “sum allselect” as columns, showing in the below screenshot.


    Intuitively, I use ALLSELECTED without parameters, which means to retrieve the original filter context.

    VALUES function is used to convert the column reference into a single column table. While I use the values in the formula which computes the values for the individual rows.

    sum allselect values:=CALCULATE(SUM(Custom7[Column1]),ALLSELECTED(),VALUES(Custom7[ID]))

    Then you can see the results in below screenshot.



    If you have any questions, please don’t hesitate to let me know.

     

    Regards,
    Angelia


    Friday, September 23, 2016 6:46 AM