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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
bballjoe12
Frequent Visitor

Help with Syntax to keep rows if date is not modified within 48 hours?

I'm new to Power BI and trying to use the Advanced Editor and add syntax to keep the rows if the last modified date is not within the last 48 hours. Here is my code so far:

 

 

let
    Source = #"Ticket Data",
    #"Null Target Date" = Table.SelectRows(#"Source", each ([Target Date] = null or (DateTime.LocalNow() > [Target Date] ))),
    #"Changed Type" = Table.TransformColumnTypes(#"Null Target Date",{{"Submitted Date", type datetime}, {"Last Modified Date", type datetime}, {"Target Date", type datetime}})
in
    #"Changed Type"

 

 

I have a column named "Last Modified Date" in the format of:

4/8/2021 3:42:34 PM

 

My table is pulled from a .json from a Sharepoint file which includes tickets in a queue and details about the ticket.  How would I add another OR statement to include rows where "Last modified date" is NOT within the last 48 hours?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

 

try this ( I modified your script by adding the expression that checks if [target data] is before the last 48 hours )

 

 




let
    Source = #"Ticket Data",
    #"Null Target Date" = Table.SelectRows(#"Source", each [Target Date] = null or (not DateTime.IsInPreviousNHours([Target Date],48 ))),
    #"Changed Type" = Table.TransformColumnTypes(#"Null Target Date",{{"Submitted Date", type datetime}, {"Last Modified Date", type datetime}, {"Target Date", type datetime}})
in
    #"Changed Type"

 

 

View solution in original post

3 REPLIES 3
bballjoe12
Frequent Visitor

Thank you for this! How do I go about getting this configured? Do I need to add this table? How do I then compare my column of "Last Modified Date?"

Anonymous
Not applicable

 

try this ( I modified your script by adding the expression that checks if [target data] is before the last 48 hours )

 

 




let
    Source = #"Ticket Data",
    #"Null Target Date" = Table.SelectRows(#"Source", each [Target Date] = null or (not DateTime.IsInPreviousNHours([Target Date],48 ))),
    #"Changed Type" = Table.TransformColumnTypes(#"Null Target Date",{{"Submitted Date", type datetime}, {"Last Modified Date", type datetime}, {"Target Date", type datetime}})
in
    #"Changed Type"

 

 

Anonymous
Not applicable

try this

you have two differente options to choice from (2days or 48hours)

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors