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

Use/ capture selected value from a filter and use it in a New column

Hello,

I have been trying to show whether the device is online/offline based on it's last response time. I have created a new column with logic as, if the device's last response is within 2 hours then it's online and everything else is offline.

 

Here i want to make the 2 hours window as dynamic, user can pick between 1-24 hours and the logic should be 

if the device's last response is within <user selected> hours then it's online and everything else is offline.

 

if(device[devicelastresponsetime]>(UTCNOW()-TIME(selectedvalue),0,0)),"Online","Offline")
this returns blank as SELECTEDVALUE() is blank. Though as a measure this works perfectly
sharmisaranga09_0-1708950460124.png

 

 

5 REPLIES 5

I am able to get a measure working,

On/OffStatus = if(SELECTEDVALUE(device[lastresponsetime])>(UTCNOW()-TIME(SELECTEDVALUE(Parameter[Parameter]),0,0)),"Online","Offline")

Thank you.

Anonymous
Not applicable

Hi  @sharmisaranga09 ,

 

Does the above dax formula solve your problem, and if it doesn't meet your expected results, can you share sample data and sample output in tabular format? Or sample pbix after removing sensitive data. We can understand the problem better and help you.

 

Best Regards,

Liu Yang

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

Hi, 

I couldn't attach pbix due to permission issue, Here is the sample I captured. DateTime is in UTC.

sharmisaranga09_0-1709013862790.png

 

Hi, Thank you.
I have multiple devices with single devicelastresponsetime value each, this gets updated whenever new response receives.
I still get all the values as offline eventhough I have chosen higher parameter value from your pbix report.
were you able to get the changes for selected value from slicer or have you used default value in parameter configuration?

sharmisaranga09_0-1709011480997.png

 

 

Anonymous
Not applicable

Hi  @sharmisaranga09 ,

 

Here are the steps you can follow:

 

If you have more than one device, you can use the following dax.

Create measure

Group_date =
var _maxdate= MAXX(FILTER(ALL('device'),'device'[device_name]=MAX('device'[device_name])),[devicelastresponsetime])
var _hour=DATEDIFF(_maxdate,NOW(),HOUR)
return
IF(
    _hour=SELECTEDVALUE('Parameter'[Parameter]),"Online","Offline")

vyangliumsft_0-1708998150943.png

If you have a device, you can use the following dax.

Create measure

Single_date =
var _maxdate= MAXX(ALL('device'),[devicelastresponsetime])
var _hour=DATEDIFF(_maxdate,NOW(),HOUR)
return
IF(
    _hour=SELECTEDVALUE('Parameter'[Parameter]),"Online","Offline")

vyangliumsft_1-1708998150944.png

 

 

Best Regards,

Liu Yang

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

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.