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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Michie_24
Frequent Visitor

Count Dynamic Overdue Flag

Hi, 

 

Here is my example data. I would like to count the number of overdues for each months.

 

For example, Request C and D is "Not Overdue" if it is based on the month of February, but it will be "Overdue" when it is on March. I would like to have a graph that shows the accumulated number of Overdues for each month. Any leads would be helpful. 

Michie_24_0-1672143779434.png

 

1 ACCEPTED SOLUTION
adudani
Super User
Super User

Hi @Michie_24

 

steps taken:

1. Created a conditional column in power query to check if Today is greater than the Target Date. Today will dynamically update based on your system locale.

2. If yes, overdue else not.

3. Note: Change the Today parameter in the conditional statement if any other date is required for this comparison.

 

CODE:

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjDUByIjAyMjJR0lRyAG8gxNYQIgjgmM45yTX5yaohSrA9RlhKTLCaTQSN/IAq7LCMkIVF1I4ui6QAimygwm6IJVVSwA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Submitted Date" = _t, #"Request ID" = _t, #"Target Date" = _t, #"Archived Date" = _t, Status = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Submitted Date", type date}, {"Request ID", type text}, {"Target Date", type date}, {"Archived Date", type date}, {"Status", type text}}),
OverdueFlag = Table.AddColumn(#"Changed Type", "Overdue Flag", each if Date.From(DateTime.LocalNow()) > [Target Date] then "Overdue" else "Not Overdue")
in
OverdueFlag

 

Furthermore, load this data into the report view.

4. Create the following measure:

 

Overdue count = CALCULATE( COUNT('Table (2)'[Overdue Flag]), 'Table (2)'[Overdue Flag] = "Overdue").
 
Please accept this solution if the query is resolved.
Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a Kudos 🙂
Kind Regards,
Avinash

View solution in original post

1 REPLY 1
adudani
Super User
Super User

Hi @Michie_24

 

steps taken:

1. Created a conditional column in power query to check if Today is greater than the Target Date. Today will dynamically update based on your system locale.

2. If yes, overdue else not.

3. Note: Change the Today parameter in the conditional statement if any other date is required for this comparison.

 

CODE:

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjDUByIjAyMjJR0lRyAG8gxNYQIgjgmM45yTX5yaohSrA9RlhKTLCaTQSN/IAq7LCMkIVF1I4ui6QAimygwm6IJVVSwA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Submitted Date" = _t, #"Request ID" = _t, #"Target Date" = _t, #"Archived Date" = _t, Status = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Submitted Date", type date}, {"Request ID", type text}, {"Target Date", type date}, {"Archived Date", type date}, {"Status", type text}}),
OverdueFlag = Table.AddColumn(#"Changed Type", "Overdue Flag", each if Date.From(DateTime.LocalNow()) > [Target Date] then "Overdue" else "Not Overdue")
in
OverdueFlag

 

Furthermore, load this data into the report view.

4. Create the following measure:

 

Overdue count = CALCULATE( COUNT('Table (2)'[Overdue Flag]), 'Table (2)'[Overdue Flag] = "Overdue").
 
Please accept this solution if the query is resolved.
Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a Kudos 🙂
Kind Regards,
Avinash

Helpful resources

Announcements
Fabcon_Europe_Social_Bogo

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.