Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
cwfmoore
Regular Visitor

Using multiple values from slicer in CALCULATE DAX expression

Hello,

 

I have a PowerBI dashboard which has a date table connected to a table of student applications.  I also have a slicer of academic years.

 

I would like to be able to capture the multiple selections made on the slicer to be used in further DAX expressions in a CALCULATE statement.

 

For example: (psuedo code)

VAR selected_years = SELECTEDVALUE('Date'[Academic Years])

VAR calc =
      CALCULATE(COUNT('Student Applications'[Id])

             FILTER(

             'Date',

              'Date'[Academic Years] IN selected_years

             )

        )

RETURN calc

 

date_slicer.pngstudent_table.png

1 ACCEPTED SOLUTION
SpartaBI
Community Champion
Community Champion

@cwfmoore 

VAR selected_years = VALUES('Date'[Academic Years])

VAR calc =
      CALCULATE(COUNT('Student Applications'[Id])

             FILTER(

             'Date',

              'Date'[Academic Years] IN selected_years

             )

        )

RETURN calc

If you do SELECTEDVALUE it will only return that value if there is one and for multiple choices will default to blank.
In general , if you just want to capture the years selcted then you don't need to do anything cause they are already taken by default in the filter context on measures that acts on related table.
So, for instance, this would have given you the same result:
COUNT('Student Applications'[Id])

btw, also this would give you the same result per yoor pseudo code:

VAR selected_years = VALUES('Date'[Academic Years])

VAR calc =
      CALCULATE(
             COUNT('Student Applications'[Id]),

             selected_years

      )

RETURN calc


2022-05-19 17_30_22-Re_ Need help on DAX function with measure vs colu... - Microsoft Power BI Commu.png

Showcase Report – Contoso By SpartaBI


SpartaBI_3-1652115470761.png   SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Full-Logo11.png

View solution in original post

1 REPLY 1
SpartaBI
Community Champion
Community Champion

@cwfmoore 

VAR selected_years = VALUES('Date'[Academic Years])

VAR calc =
      CALCULATE(COUNT('Student Applications'[Id])

             FILTER(

             'Date',

              'Date'[Academic Years] IN selected_years

             )

        )

RETURN calc

If you do SELECTEDVALUE it will only return that value if there is one and for multiple choices will default to blank.
In general , if you just want to capture the years selcted then you don't need to do anything cause they are already taken by default in the filter context on measures that acts on related table.
So, for instance, this would have given you the same result:
COUNT('Student Applications'[Id])

btw, also this would give you the same result per yoor pseudo code:

VAR selected_years = VALUES('Date'[Academic Years])

VAR calc =
      CALCULATE(
             COUNT('Student Applications'[Id]),

             selected_years

      )

RETURN calc


2022-05-19 17_30_22-Re_ Need help on DAX function with measure vs colu... - Microsoft Power BI Commu.png

Showcase Report – Contoso By SpartaBI


SpartaBI_3-1652115470761.png   SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Full-Logo11.png

Helpful resources

Announcements
October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.