Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Nishant77Goel
Frequent Visitor

How to used slicer selected column in formulas

Help needed!
Selected Parameter = maxx(filter('Date Value', 'Date Value'[Date Value Order] = SELECTEDVALUE('Date Value'[Date Value Order])), 'Date Value'[Date Value Fields])


This returns the name of selected column in slicer created using field parameter.

Now based on the selected column name wants to calculate dates that falls in last 180 days on that particular column.
Last 180 days flag = IF([Selected Parameter] > (TODAY()-180),"1","0")
This is giving error, value coming from selected parameter is not considered as column but is considered as text. So it's not matching up with today()-180 days condition.
The values in Slicer are 4 different date columns in date time format. Value coming from selected parameter is not considered as column but is considered as text. So, it's not matching up with today()-180 days condition. If I directly consider creating column the formula is working fine.
Please suggest any alternative appraoch.

2 REPLIES 2
Nishant77Goel
Frequent Visitor

Hi @v-yangliu-msft  ,

Thanks for your help.

This is not working as desired. Attaching test dashboard for your reference. The columnis not pulling desired 1 or 0 value. I have 4 columns in slicer - "LAST_OPPORTUNITY_CHANGE_DT", "MBR_PGM_CREATE_DT", “MBR_PGM_ENROLL_DT","OPPORTUNITY_CREATE_DT"

Based on date selection want to create the formula to check if the selected date is falling in last 180 days or not. Could you please help.

 

Thanks,

Nishant

 

Capture.PNG

v-yangliu-msft
Community Support
Community Support

Hi  @Nishant77Goel ,

If the result of [Selected Parameter] is text, it cannot be compared with Date, and the format is different.

 

If you want to compare the value of Filter with TODAY()-180 directly, you can try the following formula directly:

Last 180 days flag =
var _select=SELECTEDVALUE('Table'[date value order])
return
IF(
    _select>TODAY() -180,1,0)

vyangliumsft_0-1668132079887.png

 

 

If the results don't meet your expectations, can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data. We can better understand the problem 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.

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.