The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
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.
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) =
Is this posible to call parameter in dax?
Thank you !
Solved! Go to Solution.
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,
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!
User | Count |
---|---|
28 | |
11 | |
8 | |
6 | |
5 |
User | Count |
---|---|
35 | |
14 | |
12 | |
9 | |
7 |