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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
siddrow
Helper III
Helper III

Help with custom column for filtering

Hi

 

I've created the below custom column which I will then use to create a measure to switch the colour of the font in a visual (1 week = red, 2 weeks = orange, 1 month = red) and also use as a filter to only show on 1 week, 2 weeks and 1 month data in my visual.

 

if [Due Date]-[#"Today's Date"] <=7 and [#"Total % Complete"] = 0 then "1 Week"
else if [Due Date]-[#"Today's Date"] >7 and [Due Date]-[#"Today's Date"] <=14 and [#"Total % Complete"] <0.8 then "2 Weeks"
else if [Due Date]-[#"Today's Date"] >14 and [Due Date]-[#"Today's Date"] <=30 and [#"Total % Complete"] <0.9 then "1 Month"
else ""

 

I'm getting the below error. Due date and today's date is in date format, total % complete is % format. 

 

siddrow_0-1739233148976.png

 

What's the alternative solution to be able to do what I need to do here?

 

thanks

1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@siddrow try this:

 

if Duration.Days([Due Date]-[#"Today's Date"]) <=7 and [#"Total % Complete"] = 0 then "1 Week"
else if Duration.Days([Due Date]-[#"Today's Date"]) >7 and Duration.Days([Due Date]-[#"Today's Date"]) <=14 and [#"Total % Complete"] <0.8 then "2 Weeks"
else if Duration.Days([Due Date]-[#"Today's Date"]) >14 and Duration.Days([Due Date]-[#"Today's Date"]) <=30 and [#"Total % Complete"] <0.9 then "1 Month"
else ""


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

2 REPLIES 2
parry2k
Super User
Super User

@siddrow try this:

 

if Duration.Days([Due Date]-[#"Today's Date"]) <=7 and [#"Total % Complete"] = 0 then "1 Week"
else if Duration.Days([Due Date]-[#"Today's Date"]) >7 and Duration.Days([Due Date]-[#"Today's Date"]) <=14 and [#"Total % Complete"] <0.8 then "2 Weeks"
else if Duration.Days([Due Date]-[#"Today's Date"]) >14 and Duration.Days([Due Date]-[#"Today's Date"]) <=30 and [#"Total % Complete"] <0.9 then "1 Month"
else ""


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Thanks so much - this worked!

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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