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

Embedding a Case in advanced editor

Hi all,

 

I am trying to modify the below M code to also handle a case where if a column "PrevClose" is True then it will be displayed regardless of what VarToday is.

 

 

    #"Filtered Rows" = Table.SelectRows(
            #"Removed Columns", 
            let
                varToday = DateTime.Date(DateTime.LocalNow()),
                varLastDay = if Date.DayOfWeek(varToday) <= 2 then Date.AddDays(varToday, 3) else 
                if Date.DayOfWeek(varToday) >= 3 then Date.AddDays(varToday, 5) else 
                Date.AddDays(varToday, 1)
            in
            each [StartDate] <= varLastDay 
            ),

 

 

 

My first though would be to add an OR statement like the below, but it is not behaving as expected.

 

 

 each [StartDate] <= varLastDay or [PrevClose] ="True"

 

 

 The end goal of this is to display all jobs due to begin within the next 3 days, including jobs starting at any point in the future if the PrevClose is True. 

1 ACCEPTED SOLUTION
pmbaranski
Frequent Visitor

If anyone else is curious, the way i accomplished this is by adding a custom conditional column where PrevClose being True is equal to 1, and then inserting the OR statement like below; 

    #"Filtered Rows" = Table.SelectRows(
            #"Added Conditional Column", 
            let
                varToday = DateTime.Date(DateTime.LocalNow()),
                varLastDay = if Date.DayOfWeek(varToday) <= 2 then Date.AddDays(varToday, 3) else if Date.DayOfWeek(varToday) >= 3 then Date.AddDays(varToday, 5) else Date.AddDays(varToday, 1)
            in
            each [StartDate] <= varLastDay or [Custom] = 1),

View solution in original post

1 REPLY 1
pmbaranski
Frequent Visitor

If anyone else is curious, the way i accomplished this is by adding a custom conditional column where PrevClose being True is equal to 1, and then inserting the OR statement like below; 

    #"Filtered Rows" = Table.SelectRows(
            #"Added Conditional Column", 
            let
                varToday = DateTime.Date(DateTime.LocalNow()),
                varLastDay = if Date.DayOfWeek(varToday) <= 2 then Date.AddDays(varToday, 3) else if Date.DayOfWeek(varToday) >= 3 then Date.AddDays(varToday, 5) else Date.AddDays(varToday, 1)
            in
            each [StartDate] <= varLastDay or [Custom] = 1),

View solution in original post

Helpful resources

Announcements
PBI_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

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.

Get Ready for Power BI Dev Camp

Microsoft named a Leader in The Forrester Wave

Microsoft received the highest score of any vendor in both the strategy and current offering categories.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Top Kudoed Authors