cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
pvtrinh89
Frequent Visitor

Calculate days range between dates

Hi,

I have a table containing the expired date of product, so now i want to crate a report to track the citeria for them. in fact, i need to count how many product that have the number of days till exprired date <30 ||  30<exprired date<60|| 60< exprired date<90 and >90 days..

 

Could any one give me some advice on that ?

 

Best regards,
J.

1 ACCEPTED SOLUTION
v-shex-msft
Community Support
Community Support

Hi @pvtrinh89,

 

You can follow below steps to get the count of days range:

1. Create a test table.
Capture.PNG 

 

2. Add the measure to calculate the range.

exprired range =
var temp= MAX(Sheet6[exprired date])
var daynumber= DATEDIFF(min(TODAY(),temp),MAX(TODAY(),temp),DAY)
return
if(daynumber <30,"<30",if( AND(daynumber>30,daynumber<60),"30~60",if(AND(daynumber>60,daynumber<90),"60~90",">90")))

 

3. Add a calculate column to store the “range”.

Capture2.PNG
 

3. Create a new table to get the summarize information.

Table = DISTINCT( SELECTCOLUMNS(Sheet6,"Range",[Range],"Count",COUNTAX(FILTER(Sheet6,[Range]=EARLIER(Sheet6[Range])),[Range])))
 Capture3.PNG


Regards,
Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

2 REPLIES 2
v-shex-msft
Community Support
Community Support

Hi @pvtrinh89,

 

You can follow below steps to get the count of days range:

1. Create a test table.
Capture.PNG 

 

2. Add the measure to calculate the range.

exprired range =
var temp= MAX(Sheet6[exprired date])
var daynumber= DATEDIFF(min(TODAY(),temp),MAX(TODAY(),temp),DAY)
return
if(daynumber <30,"<30",if( AND(daynumber>30,daynumber<60),"30~60",if(AND(daynumber>60,daynumber<90),"60~90",">90")))

 

3. Add a calculate column to store the “range”.

Capture2.PNG
 

3. Create a new table to get the summarize information.

Table = DISTINCT( SELECTCOLUMNS(Sheet6,"Range",[Range],"Count",COUNTAX(FILTER(Sheet6,[Range]=EARLIER(Sheet6[Range])),[Range])))
 Capture3.PNG


Regards,
Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

BhaveshPatel
Community Champion
Community Champion

Hi J.

 

Please refer to the following link for more detailed classification approach.

 

 

Thanks & Regards,

Bhavesh

 

Thanks & Regards,
Bhavesh

Love the Self Service BI.
Please use the 'Mark as answer' link to mark a post that answers your question. If you find a reply helpful, please remember to give Kudos.

Helpful resources

Announcements
MBAS on Demand

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

July 2021 Update 768x460.png

Check it out!

Click here to read more about the July 2021 Updates

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Urdu Hindi D365 Bootcamp 768x460.png

Urdu Hindi D365 Bootcamp

Dont miss our very own April Dunnam’s The Developer Guide to the Galaxy! Find out what the Power Platform has to offer for the traditional developer.

Top Solution Authors
Top Kudoed Authors