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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
tomperro
Helper V
Helper V

Best Practice for Storing Commonly Used Variables / Parameters

Is there a way to store commonly used variables in a table or other way?
For eample, I am using a measure to determine which employees are considered new hires.
Currently, I am looking for anyone that has been employed for 1 year or less and marking them as a new hire. 

If I decide that I want to make anyone employed for 2 years or less a new hire, I can modidy my formula but I would like to store the 1 year or 2 year filter in a table so I can make the change in just one place.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @tomperro ,

I create a new table.

Table = DATATABLE("NewHireThreshold",INTEGER,{{12}})

vyilongmsft_0-1712201282155.png

Then I create another table as you mentioned.

vyilongmsft_1-1712201329004.png

There is a  measure and here is the DAX code.

IsNewHire =
IF (
    DATEDIFF ( TODAY (), MAX ( 'Employee'[HireDate] ), MONTH )
        >= MAX ( 'Table'[NewHireThreshold] ),
    "Yes",
    "No"
)

vyilongmsft_2-1712201441510.png

 

 

 

Best Regards

Yilong Zhou

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

2 REPLIES 2
Anonymous
Not applicable

Hi @tomperro ,

I create a new table.

Table = DATATABLE("NewHireThreshold",INTEGER,{{12}})

vyilongmsft_0-1712201282155.png

Then I create another table as you mentioned.

vyilongmsft_1-1712201329004.png

There is a  measure and here is the DAX code.

IsNewHire =
IF (
    DATEDIFF ( TODAY (), MAX ( 'Employee'[HireDate] ), MONTH )
        >= MAX ( 'Table'[NewHireThreshold] ),
    "Yes",
    "No"
)

vyilongmsft_2-1712201441510.png

 

 

 

Best Regards

Yilong Zhou

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

Khushidesai0109
Super User
Super User

  1. Create a Parameter Table: Create a new table in your Power BI model where you will store your parameters. This table will have at least two columns: one for the parameter name and one for its value.

  2. Define Parameters: Populate this table with the parameters you want to use in your calculations. For example, in your case, you might have a row in this table with the parameter name "New Hire Threshold" and the value "1 Year".

  3. Reference Parameters in Measures: Modify your measure to reference the parameter value from the parameter table. For example, instead of hardcoding "1 Year" in your calculation, you would reference the value stored in the parameter table.

Here's an example of how your parameter table might look:

Parameter Name Value

New Hire Threshold1 Year

 

 

And here's how you might modify your measure to use this parameter:

 

 

New Hire Status =
VAR NewHireThreshold = SELECTEDVALUE(ParameterTable[Value])
RETURN
IF(
[Employee Tenure] <= NewHireThreshold,
"New Hire",
"Existing Employee"
)

This way, if you decide to change the threshold for new hires from 1 year to 2 years, you would just need to update the value in the parameter table, and all measures referencing that parameter will automatically reflect the change.



Please give thumbs up and accept it as solution if it helped you!!


Proud to be a Super User!!

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors