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
Mokegubshook
Helper I
Helper I

How to Call Parameter in DAX for Measure

Hi, I have a problem with field parameter

 

I have table like this:

Time Table will store time 1 and time 2 for selection. If user selected Time 1, I need to compare Time 1 by app with Deliverytime.

Mokegubshook_2-1742477733252.png

 

What I Do now is:

1. Create Field Parameter for selecting Time1 and Time2 --> This will return data of time 1 or time 2 in each app.

2. Create DAX 

 

Complete Gap by view (Conservative) (Round) =

VAR TimeDifference = DATEDIFF(I need to replace with Parameter base on Time1 or Time2 selection, [DeliveredTime)], SECOND) / 60
RETURN
IF(
    WEEKDAY(Query1[DATE]) IN {1, 7}|| ISBLANK(Query1[DATE]),
    BLANK(),
    CEILING(TimeDifference, 1)
)
 
My Dashboard should looklike:
Mokegubshook_0-1742479051248.png

 

Is this posible to call parameter in dax?

Thank you !

 

1 ACCEPTED SOLUTION
DataNinja777
Super User
Super User

Hi @Mokegubshook ,

 

You can call a field parameter in a DAX measure to dynamically switch between Time1 and Time2 based on user selection. First, you need to create a field parameter that allows users to select either Time1 or Time2. The parameter table should look like this:

Time Selection = 
    UNION(
        SELECTCOLUMNS( {'Time 1'}, "Selection", "Time 1"),
        SELECTCOLUMNS( {'Time 2'}, "Selection", "Time 2")
    )

Once the field parameter is created, you can modify your DAX measure to use the selected parameter dynamically. The measure should determine whether the user selected Time1 or Time2 and then calculate the time difference accordingly.

Complete Gap by View (Conservative) (Round) =
VAR SelectedTime = 
    SWITCH(
        SELECTEDVALUE('Time Selection'[Selection]), 
        "Time 1", SELECTEDVALUE('Time Table'[Time 1]), 
        "Time 2", SELECTEDVALUE('Time Table'[Time 2])
    )

VAR TimeDifference = DATEDIFF(SelectedTime, SELECTEDVALUE(Query1[DeliveredTime]), SECOND) / 60

RETURN
IF(
    WEEKDAY(Query1[DATE]) IN {1, 7} || ISBLANK(Query1[DATE]),
    BLANK(),
    CEILING(TimeDifference, 1)
)

This measure uses the SWITCH function to dynamically select the appropriate time value based on the field parameter selection. The DATEDIFF function then calculates the time difference between the selected time and the DeliveredTime column in seconds, which is then converted to minutes. The CEILING function ensures the result is rounded up to the nearest whole number, and an IF condition is used to exclude weekends and blank dates from the calculation. This approach ensures that your Power BI report dynamically updates based on user selections.

 

Best regards,

View solution in original post

2 REPLIES 2
DataNinja777
Super User
Super User

Hi @Mokegubshook ,

 

You can call a field parameter in a DAX measure to dynamically switch between Time1 and Time2 based on user selection. First, you need to create a field parameter that allows users to select either Time1 or Time2. The parameter table should look like this:

Time Selection = 
    UNION(
        SELECTCOLUMNS( {'Time 1'}, "Selection", "Time 1"),
        SELECTCOLUMNS( {'Time 2'}, "Selection", "Time 2")
    )

Once the field parameter is created, you can modify your DAX measure to use the selected parameter dynamically. The measure should determine whether the user selected Time1 or Time2 and then calculate the time difference accordingly.

Complete Gap by View (Conservative) (Round) =
VAR SelectedTime = 
    SWITCH(
        SELECTEDVALUE('Time Selection'[Selection]), 
        "Time 1", SELECTEDVALUE('Time Table'[Time 1]), 
        "Time 2", SELECTEDVALUE('Time Table'[Time 2])
    )

VAR TimeDifference = DATEDIFF(SelectedTime, SELECTEDVALUE(Query1[DeliveredTime]), SECOND) / 60

RETURN
IF(
    WEEKDAY(Query1[DATE]) IN {1, 7} || ISBLANK(Query1[DATE]),
    BLANK(),
    CEILING(TimeDifference, 1)
)

This measure uses the SWITCH function to dynamically select the appropriate time value based on the field parameter selection. The DATEDIFF function then calculates the time difference between the selected time and the DeliveredTime column in seconds, which is then converted to minutes. The CEILING function ensures the result is rounded up to the nearest whole number, and an IF condition is used to exclude weekends and blank dates from the calculation. This approach ensures that your Power BI report dynamically updates based on user selections.

 

Best regards,

Thank you so much, Your answer save my life! 

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.