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
esuryahadi
Helper I
Helper I

due date filter

Hello,

I have table data as follows.

IDContract Name Contractstart dateEnd DateStatus
1ADB22/02/202321/04/2023done
2DFG01/06/202302/10/2023on going
3DFR19/12/202320/02/2024on going
4HGT05/05/202310/10/2023done
5KJR10/10/202312/12/2023on going

 

I want to count the number of days from the end date column with today's date with conditions
< 30 days from Today - color yellow
> today - color red
Done - color black

I've tried with datediff but it hasn't worked.

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

Hi @esuryahadi ,

 

You can also create a measure.

conditions = SWITCH(TRUE(),
MAX('Table'[Status])="done","black",
MAX('Table'[End Date]) > TODAY(),"red",
DATEDIFF(MAX('Table'[End Date]),TODAY(),DAY)<30,"yellow"
)

Setting the Conditional Format.

vtangjiemsft_0-1698916729517.png

vtangjiemsft_1-1698916768630.png

 

Best Regards,

Neeko Tang

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

View solution in original post

Anonymous
Not applicable

Hi @esuryahadi ,

 

I'm sorry I don't quite understand, the IDContract is 3 and 5 when the end date is 2024/2/20 and 2023/12/12. today's date is 2023/11/3 and the end date is greater than today, shouldn't he show red?

vtangjiemsft_0-1698989775782.png

 

According to your description,

(1) We can create a table.

Slicer = DATATABLE ( 
    "Type", STRING,
    {
        { "< 30 day"},
        { "> Today" },
        { "Done/Complete" }
    }
)

(2) We can create measures. 

conditions = SWITCH(TRUE(),
MAX('Table'[Status])="done","black",
MAX('Table'[End Date]) > TODAY(),"red",
DATEDIFF(MAX('Table'[End Date]),TODAY(),DAY)<30,"yellow"
)
Flag = SWITCH(TRUE(),
ISFILTERED('Slicer'[Type])=FALSE(),1,
SELECTEDVALUE('Slicer'[Type])="< 30 day" && [conditions]="yellow",1,
SELECTEDVALUE('Slicer'[Type])="> Today" && [conditions]="red",1,
SELECTEDVALUE('Slicer'[Type])="Done/Complete" && [conditions]="black",1,0)

(3) Setting the conditional format and filtering [Flag=1] as a visual object.

vtangjiemsft_0-1698990307842.png

Best Regards,

Neeko Tang

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

View solution in original post

10 REPLIES 10
Anonymous
Not applicable

Hi @esuryahadi ,

 

You can also create a measure.

conditions = SWITCH(TRUE(),
MAX('Table'[Status])="done","black",
MAX('Table'[End Date]) > TODAY(),"red",
DATEDIFF(MAX('Table'[End Date]),TODAY(),DAY)<30,"yellow"
)

Setting the Conditional Format.

vtangjiemsft_0-1698916729517.png

vtangjiemsft_1-1698916768630.png

 

Best Regards,

Neeko Tang

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

Anonymous
Not applicable

Hi @esuryahadi ,

 

I can't access the link you shared, it seems to have no permissions. Please re-share it.


Referring to my second reply, you can create the measure and then set the conditional format. Refer my pbix file.

May I ask if you have tried the code I provided? If the output does not match your expected results, please show your input data and expected results in detail.

vtangjiemsft_1-1698975811011.png

 

 conditions = SWITCH(TRUE(),
MAX('YourTableName'[Status])="done","black",
MAX('YourTableName'[End Date]) > TODAY(),"red",
DATEDIFF(MAX('YourTableName'[End Date]),TODAY(),DAY)<30,"yellow"
)

 

 

Best Regards,

Neeko Tang

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

Anonymous
Not applicable

Hi @esuryahadi ,

 

According to your description, here are my steps you can follow as a solution.

(1) My test data is the same as yours.

(2) We can create a measure. 

conditions = SWITCH(TRUE(),
MAX('Table'[Status])="done","black",
MAX('Table'[End Date]) > TODAY(),"red",
DATEDIFF(MAX('Table'[End Date]),TODAY(),DAY)<30,"yellow"
)

(3) Then the result is as follows.

vtangjiemsft_0-1698894327874.png

 

vtangjiemsft_1-1698894367461.png

 

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

 

Best Regards,

Neeko Tang

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

Hi, Sorry i have problem about my data.

But so far my data is same.

after i try you code, still have wrong 

vtangjiemsft_.png

in IDContract 3 and 5 shouldn't not red. 

and i want to visual like pic 

 

Screenshot 2023.jpeg

Very sorry if my Language is bad

Anonymous
Not applicable

Hi @esuryahadi ,

 

I'm sorry I don't quite understand, the IDContract is 3 and 5 when the end date is 2024/2/20 and 2023/12/12. today's date is 2023/11/3 and the end date is greater than today, shouldn't he show red?

vtangjiemsft_0-1698989775782.png

 

According to your description,

(1) We can create a table.

Slicer = DATATABLE ( 
    "Type", STRING,
    {
        { "< 30 day"},
        { "> Today" },
        { "Done/Complete" }
    }
)

(2) We can create measures. 

conditions = SWITCH(TRUE(),
MAX('Table'[Status])="done","black",
MAX('Table'[End Date]) > TODAY(),"red",
DATEDIFF(MAX('Table'[End Date]),TODAY(),DAY)<30,"yellow"
)
Flag = SWITCH(TRUE(),
ISFILTERED('Slicer'[Type])=FALSE(),1,
SELECTEDVALUE('Slicer'[Type])="< 30 day" && [conditions]="yellow",1,
SELECTEDVALUE('Slicer'[Type])="> Today" && [conditions]="red",1,
SELECTEDVALUE('Slicer'[Type])="Done/Complete" && [conditions]="black",1,0)

(3) Setting the conditional format and filtering [Flag=1] as a visual object.

vtangjiemsft_0-1698990307842.png

Best Regards,

Neeko Tang

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

Thank you very much you help.

 

Hi Neeko Tang,

Sorry, you right.

I was wrong in explaining. 

What I mean is 

colume end date < 30 days from today - yellow and count how many IDContract

colume end date > from Today - Red and count how many IDContract

colume status done - black and count how many IDContract.

 

I hope you can understand.

Thank you very much so far your help

 

Regads,

Eko

 

Anonymous
Not applicable

Hi @esuryahadi ,

 

You need to create another measure.

Count = SWITCH(TRUE(),
ISFILTERED('Slicer'[Type])=FALSE(),COUNTROWS(ALLSELECTED('Table')),
SELECTEDVALUE('Slicer'[Type])="< 30 day",COUNTROWS(FILTER(ALLSELECTED('Table'),[conditions]="yellow")),
SELECTEDVALUE('Slicer'[Type])="> Today" ,COUNTROWS(FILTER(ALLSELECTED('Table'),[conditions]="red")),
SELECTEDVALUE('Slicer'[Type])="Done/Complete",COUNTROWS(FILTER(ALLSELECTED('Table'),[conditions]="black")))

vtangjiemsft_0-1698998234722.png

Best Regards,

Neeko Tang

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

Thank you.

 This my data. 

Sorry i try to attactment file csv and pbix is fail.

No WBSIndex TitleNo Contract Total USD Start DateEnd DateStatus
C8000006System WTP 3456 $3,45 21/10/201923/10/2019Done
C8000007Constrution WTP2987 $1,25 21/10/202023/10/2021Done
C8000008Upgrading Submarine Hose876 $1,25 01/10/202302/11/2023On Going
C8000009Main Gathering Station7409 $0,13 30/10/202301/11/2023On Going
C8000010Upgrading Ring Main1928 $0,17 24/02/202027/02/2020Done
C8000011Install New Oil Trunkline23 $0,14 02/10/202301/12/2023On Going
C8000012System Cathodic Protection 923 $0,41 01/10/202301/12/2023On Going
C8000013Intertank Pump 600 92 $0,06 19/09/202320/10/2023On Going
C8000014Handheld Oil Analyzer8634 $104,32 20/10/202303/01/2024On Going

 

No WBSIndex TitleNo Contract Total USD Start DateEnd DateStatus
C8000006System WTP 3456 $3,45 ################Done
C8000007Constrution WTP2987 $1,25 ################Done
C8000008Upgrading Submarine Hose876 $1,25 ################On Going
C8000009Main Gathering Station7409 $0,13 ################On Going
C8000010Upgrading Ring Main1928 $0,17 ################Done
C8000011Install New Oil Trunkline23 $0,14 ################On Going
C8000012System Cathodic Protection 923 $0,41 ################On Going
C8000013Intertank Pump 600 92 $0,06 ################On Going
C8000014Handheld Oil Analyzer8634 $104,32 ################On Going

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.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.