Forum Discussion
Issue with DAX Filter via Web URL
- 1 year ago
Hi CoderV9 ,
You are absolutely right - hardcoding values like 202501 or "WXYZ" inside the DAX won't allow dynamic filtering through the URL or PowerApps.
Here's how to make your DAX work with URL filters:
You don't need to extract values manually into variables (like varDate, varMgrID) when you're relying on URL-based filtering - instead, let Power BI's filter context do the job.Try using below DAX:
Team_Vol =CALCULATE(COUNTROWS(tbl_incidents),REMOVEFILTERS(tbl_incidents), -- Optional: removes other filters if neededtbl_incidents[Close_datecode],tbl_incidents[managerid])Individual_Vol =CALCULATE(COUNTROWS(tbl_incidents),REMOVEFILTERS(tbl_incidents),tbl_incidents[Close_datecode],tbl_incidents[userid])The key here is to not use SELECTEDVALUE or variables.Power BI already applies filters via the URL context, and CALCULATE picks them up directly.
URL Filter Format:
https://app.powerbi.com/....?filter=tbl_incidents/Close_datecode eq 202501 and tbl_incidents/managerid eq 'WXYZ' and tbl_incidents/userid eq 'ABCD'
Use no quotes for numeric fields (like Close_datecode).
Use single quotes for string fields (managerid, userid).
If this post helps, then please consider Accepting as solution to help the other members find it more quickly, don't forget to give a "Kudos" – I’d truly appreciate it!
Thank you.
Hi CoderV9 ,
Thank you for reaching out to Microsoft Fabric Community.
Here are some steps to follow to solve the issue:
To ensure consistent behavior across different platforms, especially when using URL filters or embedding in PowerApps, it's advisable to avoid relying on SELECTEDVALUE for capturing filter values. Instead, restructure your DAX measures to directly utilize the filter context provided by the URL parameters.
Please try using below DAX:
Team_Vol =
CALCULATE(
COUNTROWS(tbl_incidents),
FILTER(
tbl_incidents,
tbl_incidents[Close_datecode] = 202501 &&
tbl_incidents[managerid] = "WXYZ"
)
)
Individual_Vol =
CALCULATE(
COUNTROWS(tbl_incidents),
FILTER(
tbl_incidents,
tbl_incidents[Close_datecode] = 202501 &&
tbl_incidents[userid] = "ABCD"
)
)
In these measures:
Replace 202501 with the desired Close_datecode.
Replace "WXYZ" with the specific managerid.
Replace "ABCD" with the specific userid.
URL Filter Syntax:
When constructing the URL to pass filters, use the following format:
?filter=tbl_incidents/Close_datecode eq 202501 and tbl_incidents/managerid eq 'WXYZ' and tbl_incidents/userid eq 'ABCD'
Ensure that:
String values are enclosed in single quotes.
Numeric values are not enclosed in quotes.
By structuring your measures and URL filters in this manner, you create a direct and reliable linkage between the filters applied via the URL and the data evaluated in your DAX measures, leading to consistent and expected results across different platforms.
If this post helps, then please consider Accepting as solution to help the other members find it more quickly, don't forget to give a "Kudos" – I’d truly appreciate it!
Thank you.
- CoderV91 year agoNew Member
HI v-venuppu Thanky you for the guidance. How do i then pass the filters from URL to the DAX ?
Eg here : tbl_incidents[Close_datecode] = 202501 && tbl_incidents[managerid] = "WXYZ"
the values 202501 and WXYZ should be passed via the URL.
Directly assigning the values from URL to DAX didnt work either.