Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Column to reflect overdue items

Hi,   Need help in creating a new column that will tell me if the item is already overdue, with the following conditions:  - If Planning Date >Date Today and Custom Status = Open,  "Overdue"...
  • DataNinja777's avatar
    DataNinja777
    2 years ago

    Hi Anonymous ,

     

    There are many ways to produce your required output by using Power Query and/ or dax.  In order to fix the "Today Date", I used the combined methodology of power query and dax as show below.  

    First, add a custom column in Power Query to fix today's date and rename the column to "Date Today", as you specified. 

        #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each Date.From(DateTime.LocalNow())),
        #"Renamed Columns" = Table.RenameColumns(#"Added Custom",{{"Custom", "Date Today"}})

     

    The in Power BI data model table view, write a calculated column like below:

    Overdue status = Switch(True(),
    'Table'[PLANNING DATE (UTC)]>'Table'[Date Today]&&'Table'[Custom Status]="Open","Overdue",
    'Table'[PLANNING DATE (UTC)]<'Table'[Date Today]&&'Table'[Custom Status]="Open","On-Track",
    'Table'[PLANNING DATE (UTC)]=blank()&&'Table'[Custom Status]="Open","Unplanned",
    'Table'[Custom Status]="Solved","Done")

    The resultant output is as shown below:

    I attach an example pbix file.