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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
ashwinkolte
Helper II
Helper II

static variable / parameter to be used across measures

Hi 

 

I am using calculate function extensively for creating many measures . However for many measures the filter condition of the Calculate  is common (example shown below) .  Is there any way to create a filter variable or parameter or something to store this filter which I can refer/use in calculate functions of different measures as filter condition 

 

 

Table[Fieldintable] = "abc" ||
Table[Fieldintable] = "def" ||
Table[Fieldintable] = "ghi" ||
Table[Fieldintable] = "ljk"

1 ACCEPTED SOLUTION

Hi @ashwinkolte ,

@amitchandak Thanks for your  reply!

@ashwinkolte If I understand you correctly, you mean to somehow reference this entire DAX without having to rewrite this code all over again in another DAX?

vjunyantmsft_0-1721721464737.png

I'm sorry this can't be done in DAX because this DAX is not complete, you can only store a complete DAX in Desktop (i.e. one that can output results properly) and not just a few lines of code.
If it is too much trouble for you to list all the conditions that need to be met by the Fieldintable each time, you can try the following:
Use this DAX to create a calculated table:

Slicer = VALUES('Table'[Fieldintable])

vjunyantmsft_1-1721721776566.png

vjunyantmsft_2-1721721794556.png

Use this table to create a slicer:

vjunyantmsft_3-1721721823495.png

Then you can change your DAX like this (for example)

Measure = 
CALCULATE(
    SUM('Table'[Value]),
    'Table'[Fieldintable] IN VALUES(Slicer[Fieldintable])
)

What you need to calculate in Fieldintable, you just need to select it in slicer, no need to list them one by one in DAX.

vjunyantmsft_4-1721721965288.png


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

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

@ashwinkolte , You can use in

example

Table[Fieldintable] IN { "abc", "def", "ghi", "ljk" }

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

HI @amitchandak  Thanks for responding but that was not my question .I want to use that whole expression whther you use "=" or "IN" in other measures . So how can I have it in a parameter or a globally avaliable variable which I can just input as a filter value of Calculate function in other measures , rather than specifying all those values again in another measure . Hope the question is clear 

Hi @ashwinkolte ,

@amitchandak Thanks for your  reply!

@ashwinkolte If I understand you correctly, you mean to somehow reference this entire DAX without having to rewrite this code all over again in another DAX?

vjunyantmsft_0-1721721464737.png

I'm sorry this can't be done in DAX because this DAX is not complete, you can only store a complete DAX in Desktop (i.e. one that can output results properly) and not just a few lines of code.
If it is too much trouble for you to list all the conditions that need to be met by the Fieldintable each time, you can try the following:
Use this DAX to create a calculated table:

Slicer = VALUES('Table'[Fieldintable])

vjunyantmsft_1-1721721776566.png

vjunyantmsft_2-1721721794556.png

Use this table to create a slicer:

vjunyantmsft_3-1721721823495.png

Then you can change your DAX like this (for example)

Measure = 
CALCULATE(
    SUM('Table'[Value]),
    'Table'[Fieldintable] IN VALUES(Slicer[Fieldintable])
)

What you need to calculate in Fieldintable, you just need to select it in slicer, no need to list them one by one in DAX.

vjunyantmsft_4-1721721965288.png


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

WOW . Thankyo so much !!

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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