Forum Discussion
Adding filters to a calculated column
- 9 months ago
Hi eem_2021 ,
If you want to pass slicer or filter value to your visual or calculations, the you can use DAX functions SELECTEDVALUE,HASONEVALUE,FILTERS etc.
these will work with measures not calculated columns .but if you want specific condition rows you can create a measure with flag one or zero.something like below example:
Is Active in Period = VAR PeriodStart = MIN('Date'[Date]) // The start date from your slicer VAR PeriodEnd = MAX('Date'[Date]) // The end date from your slicer VAR EmpStart = SELECTEDVALUE('User Posting'[Start Date]) VAR EmpEnd = SELECTEDVALUE('User Posting'[End Date]) RETURN // Logic: An employee is active if they started before the period ended... // ...AND (they are still active OR they left after the period started). IF ( EmpStart <= PeriodEnd && (ISBLANK(EmpEnd) || EmpEnd >= PeriodStart), 1, 0 )above measure will give me records empstart and empend is withing slicer selection.
If you want to work with calculated columns use string manipulation functions to create the desired columns/flags.
References:
https://community.fabric.microsoft.com/t5/Desktop/Using-measure-as-a-filter/td-p/2996922
https://www.sqlbi.com/articles/applying-a-measure-filter-in-power-bi/
https://learn.microsoft.com/en-us/dax/containsstring-function-dax
https://learn.microsoft.com/en-us/dax/containsstringexact-function-dax
https://learn.microsoft.com/en-us/dax/selectedvalue-function-dax
Please give kudos or mark it as solution once confirmed.
Thanks and Regards,
Praful
Hi eem_2021 ,
Thank you for reaching out to Microsoft Fabric Community.
Thank you amitchandak FBergamaschi xifeng_L syahmisi98 GeraldGEmerick for the prompt response.
I wanted to check if you had the opportunity to review the information provided and resolve the issue..?Please let us know if you need any further assistance.We are happy to help.
Thank you.