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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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