SOLVED

Power Query 5 days ago rule

%3CLINGO-SUB%20id%3D%22lingo-sub-1505236%22%20slang%3D%22en-US%22%3EPower%20Query%205%20days%20ago%20rule%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1505236%22%20slang%3D%22en-US%22%3E%3CP%3EIn%20the%20conditional%20column%2C%20I%20want%20to%20create%20a%20rule%20that%2C%20if%20a%20column%20value%20is%20less%20than%205%20days%20ago%2C%20then%20the%20value%20should%20be%20%22pending%22%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1505236%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EBI%20%26amp%3B%20Data%20Analysis%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPower%20BI%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1505247%22%20slang%3D%22en-US%22%3ERe%3A%20Power%20Query%205%20days%20ago%20rule%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1505247%22%20slang%3D%22en-US%22%3E%3CP%3E-ERR%3AREF-NOT-FOUND-%40Ocasio27%26nbsp%3B%3C%2FP%3E%0A%3CP%3EInsert%20first%20in%20the%20wizard%20any%20date%20you%20wish.%20In%20formula%20bar%20it%20will%20be%20something%20like%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-powerquery%22%3E%3CCODE%3E%3D%20Table.AddColumn(%23%22Changed%20Type%22%2C%20%22Custom%22%2C%20each%20if%20%5BA%5D%20%26gt%3B%20%23date(2020%2C%207%2C%202)%20then%20%22pending%22%20else%20null)%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3Eand%20be%20sure%20formula%20works%20with%20your%20data.%20After%20in%20formula%20bar%20change%20%23date(...)%20on%26nbsp%3BDate.From(Date.AddDays(DateTime.LocalNow()%2C-5))%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-powerquery%22%3E%3CCODE%3E%3D%20Table.AddColumn(%23%22Changed%20Type%22%2C%20%22Custom%22%2C%20each%20if%20%5BA%5D%20%26gt%3B%20Date.From(Date.AddDays(DateTime.LocalNow()%2C-5))%20then%20%22pending%22%20else%20null)%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1505265%22%20slang%3D%22en-US%22%3ERe%3A%20Power%20Query%205%20days%20ago%20rule%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1505265%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIt%20works%20but%20I%20explained%20it%20incorrectly%20and%20is%20not%20what%20I%20was%20expecting.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20already%20have%20a%20conditional%20column%20with%20rules%2C%20if%20else%20if%20else%2C%20I%20can%20choose%20a%20column%20with%20dates%20and%20add%20after%20a%20specific%20date%2C%20but%20I%20can%20only%20input%20a%20fixed%20date%2C%20for%20example%20june%202%20which%20is%205%20days%20ago%2C%20however%20that%20query%20will%20change%20often%20and%20I%20need%20it%20to%20apply%20this%20rule%20for%20the%20last%205%20days%20no%20matter%20when%20do%20I%20update%20it.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EMaybe%20the%20only%20way%20to%20make%20this%20work%20is%20with%20a%20custom%20column%20rather%20than%20a%20conditional%20column%2C%20but%20the%20conditional%20column%20is%20just%20easier%20to%20work%20with.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1505288%22%20slang%3D%22en-US%22%3ERe%3A%20Power%20Query%205%20days%20ago%20rule%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1505288%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F438859%22%20target%3D%22_blank%22%3E%40Ocasio27%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EConditional%20column%20is%20only%20subset%20of%20custom%20columns%20with%20user%20interface%20to%20generate%20%3CSTRONG%3Eif%20...%20then%20...%20else%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EAnyway%2C%20you%20already%20have%20some%20statement%20with%20fixed%20date.%20Stay%20on%20step%20where%20this%20formula%20was%20generated%20(or%20use%20Advanced%20editor)%20and%20change%20concrete%20date%20which%20is%20in%20form%20%23date(2020%2C7%2C2)%20or%20so%2C%20on%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20%20language-powerquery%22%3E%3CCODE%3EDate.From(Date.AddDays(DateTime.LocalNow()%2C-5))%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1508737%22%20slang%3D%22en-US%22%3ERe%3A%20Power%20Query%205%20days%20ago%20rule%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1508737%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20trying%20to%20add%20this%20as%20a%20DAX%20step%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ENote%20that%20all%20rules%20with%20%22Approved%22%20have%20priority.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CDIV%3E%3CDIV%3E%3CSPAN%3E%3D%26nbsp%3BSWITCH%26nbsp%3B(%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3BTRUE%26nbsp%3B()%2C%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E'Test'%3C%2FSPAN%3E%3CSPAN%3E%5BNumber%5D%26nbsp%3B%3D%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%22X001%22%3C%2FSPAN%3E%3CSPAN%3E%2C%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%22Approved%22%3C%2FSPAN%3E%3CSPAN%3E%2C%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E'Test'%3C%2FSPAN%3E%3CSPAN%3E%5BNumber%5D%26nbsp%3B%3D%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%22X002%22%3C%2FSPAN%3E%3CSPAN%3E%2C%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%22Approved%22%3C%2FSPAN%3E%3CSPAN%3E%2C%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E'Test'%3C%2FSPAN%3E%3CSPAN%3E%5BNumber%5D%26nbsp%3B%3D%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%22X003%22%3C%2FSPAN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PAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%22Denied%22%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E)%3C%2FSPAN%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1509458%22%20slang%3D%22en-US%22%3ERe%3A%20Power%20Query%205%20days%20ago%20rule%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1509458%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F438859%22%20target%3D%22_blank%22%3E%40Ocasio27%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI'm%20not%20sure%20what%20do%20you%20mean%20under%20%22DAX%20step%22%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1509513%22%20slang%3D%22en-US%22%3ERe%3A%20Power%20Query%205%20days%20ago%20rule%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1509513%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThat%20same%20function%20but%20in%20DAX%20language%20to%20use%20in%20Power%20Pivot%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1509535%22%20slang%3D%22en-US%22%3ERe%3A%20Power%20Query%205%20days%20ago%20rule%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1509535%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F438859%22%20target%3D%22_blank%22%3E%40Ocasio27%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYes%2C%20but%20where%3F%20-%20you%20add%20calculated%20column%20or%20measure%20or%20what%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1509613%22%20slang%3D%22en-US%22%3ERe%3A%20Power%20Query%205%20days%20ago%20rule%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1509613%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20decided%20to%20do%20the%20same%20but%20in%20Power%20Pivot%20since%20the%20data%20comes%20from%20an%20.atomsvc%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20already%20added%20a%20column%20with%20the%20following%20code%2C%20but%20I%20want%20to%20add%20a%20line%20that%2C%20if%20the%20column%20%5BDate%5D%20has%20a%20day%20that%20is%20within%20the%20last%205%20days%2C%20then%20it%20adds%20pending.%20Here%20is%20the%20code%20without%20that%20line.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ENew%20column%20is%20called%20%5BResult%5D%3C%2FP%3E%3CP%3EColumn%20%5BNumber%5D%20Is%20used%20to%20define%20if%20its%20approved%20or%20not%2C%20this%20one%20has%20priority%20no%20matter%20the%20others%3C%2FP%3E%3CP%3EColumn%20%5BDate%5D%20Is%20used%20to%20define%20as%20%22Pending%22%20if%20its%20within%20the%20last%205%20days%3C%2FP%3E%3CP%3EElse%2C%20it%20should%20be%20%22Denied%22%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%5BResult%5D%3D%20SWITCH%20(%3CBR%20%2F%3ETRUE%20()%2C%3CBR%20%2F%3E'Test'%5BNumber%5D%20%3D%20%22X001%22%2C%20%22Approved%22%2C%3CBR%20%2F%3E'Test'%5BNumber%5D%20%3D%20%22X002%22%2C%20%22Approved%22%2C%3CBR%20%2F%3E'Test'%5BNumber%5D%20%3D%20%22X003%22%2C%20%22Approved%22%2C%3CBR%20%2F%3E'Test'%5BNumber%5D%20%3D%20%22X004%22%2C%20%22Approved%22%2C%3CBR%20%2F%3E'Test'%5BNumber%5D%20%3D%20%22X005%22%2C%20%22Approved%22%2C%3CBR%20%2F%3E'Test'%5BNumber%5D%20%3D%20%22X006%22%2C%20%22Approved%22%2C%3CBR%20%2F%3E'Test'%5BNumber%5D%20%3D%20%22X007%22%2C%20%22Approved%22%2C%3CBR%20%2F%3E'Test'%5BNumber%5D%20%3D%20%22X008%22%2C%20%22Approved%22%2C%3CBR%20%2F%3E'Test'%5BNumber%5D%20%3D%20%22X009%22%2C%20%22Approved%22%2C%3CBR%20%2F%3E'Test'%5BNumber%5D%20%3D%20%22X010%22%2C%20%22Approved%22%2C%3CBR%20%2F%3E%22Denied%22%3CBR%20%2F%3E)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EMy%20intention%20is%20that%2C%20unless%20is%20one%20of%20those%20number%20the%20result%20should%20be%20%22Denied%22%20with%20the%20exception%20of%20those%20with%20a%20number%20in%20the%20list%20I%20am%20adding%2C%20those%20should%20be%20%22Approved%22%20no%20matter%20if%20they%20have%20a%20date%20within%20the%20last%205%20days.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1509987%22%20slang%3D%22en-US%22%3ERe%3A%20Power%20Query%205%20days%20ago%20rule%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1509987%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F438859%22%20target%3D%22_blank%22%3E%40Ocasio27%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EPerhaps%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3DIF('Test'%5BNumber%5D%20IN%20%7B%22X001%22%2C%22X002%22%2C%22X003%22%2C%22X004%22%2C%22X005%22%2C%22X006%22%2C%22X007%22%2C%22X008%22%2C%22X009%22%2C%22X010%22%7D%2C%0A%20%20%20%20%20%20%22Approved%22%2C%0A%20%20%20%20%20%20%20IF(TODAY()-'Test'%5BDate%5D%26lt%3B%3D5%2C%22Pending%22%2C%22Denied%22))%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1510107%22%20slang%3D%22en-US%22%3ERe%3A%20Power%20Query%205%20days%20ago%20rule%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1510107%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAmazing%2C%20thank%20you.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1510177%22%20slang%3D%22en-US%22%3ERe%3A%20Power%20Query%205%20days%20ago%20rule%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1510177%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F438859%22%20target%3D%22_blank%22%3E%40Ocasio27%3C%2FA%3E%26nbsp%3B%2C%20you%20are%20welcome%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1550390%22%20slang%3D%22en-US%22%3ERe%3A%20Power%20Query%205%20days%20ago%20rule%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1550390%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESorry%20for%20the%20late%20reply%20but%2C%20how%20do%20you%20do%20that%20nice%20syntax%3F%20I%20use%20Visual%20studio%20code%20and%20is%20too%20plain%20simple.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIs%20there%20any%20%22assistant%22%20app%20to%20develop%20scripts%20in%20.m%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1551386%22%20slang%3D%22en-US%22%3ERe%3A%20Power%20Query%205%20days%20ago%20rule%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1551386%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F438859%22%20target%3D%22_blank%22%3E%40Ocasio27%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAbove%20concrete%20code%20is%20just%20in%20formula%20bar%20in%20Power%20Pivot%2C%20like%20Excel%20formulas%20in%20it's%20formula%20bar.%20Additionally%20I%20use%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdaxstudio.org%2F%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3EDAX%20Studio%3C%2FA%3E%26nbsp%3B%2C%20but%20that's%20not%20the%20code%20generator.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Frequent Contributor

In the conditional column, I want to create a rule that, if a column value is less than 5 days ago, then the value should be "pending"

13 Replies

@Ocasio27 

Insert first in the wizard any date you wish. In formula bar it will be something like

= Table.AddColumn(#"Changed Type", "Custom", each if [A] > #date(2020, 7, 2) then "pending" else null)

and be sure formula works with your data. After in formula bar change #date(...) on Date.From(Date.AddDays(DateTime.LocalNow(),-5))

= Table.AddColumn(#"Changed Type", "Custom", each if [A] > Date.From(Date.AddDays(DateTime.LocalNow(),-5)) then "pending" else null)

 

@Sergei Baklan 

 

It works but I explained it incorrectly and is not what I was expecting.

 

I already have a conditional column with rules, if else if else, I can choose a column with dates and add after a specific date, but I can only input a fixed date, for example june 2 which is 5 days ago, however that query will change often and I need it to apply this rule for the last 5 days no matter when do I update it.

 

Maybe the only way to make this work is with a custom column rather than a conditional column, but the conditional column is just easier to work with.

Best Response confirmed by Ocasio27 (Frequent Contributor)
Solution

@Ocasio27 

Conditional column is only subset of custom columns with user interface to generate if ... then ... else

Anyway, you already have some statement with fixed date. Stay on step where this formula was generated (or use Advanced editor) and change concrete date which is in form #date(2020,7,2) or so, on

Date.From(Date.AddDays(DateTime.LocalNow(),-5))

 

@Sergei Baklan 

 

I am trying to add this as a DAX step

 

Note that all rules with "Approved" have priority.

 

= SWITCH (
    TRUE (),
    'Test'[Number] = "X001""Approved",
    'Test'[Number] = "X002""Approved",
    'Test'[Number] = "X003""Approved",
    'Test'[Number] = "X004""Approved",
    'Test'[Number] = "X005""Approved",
    'Test'[Number] = "X006""Approved",
    'Test'[Number] = "X007""Approved",
    'Test'[Number] = "X008""Approved",
    'Test'[Number] = "X009""Approved",
    'Test'[Number] = "X010""Approved",
    "Denied"
)

@Ocasio27 

I'm not sure what do you mean under "DAX step"

@Sergei Baklan 

 

That same function but in DAX language to use in Power Pivot

@Ocasio27 

Yes, but where? - you add calculated column or measure or what?

@Sergei Baklan 

 

I decided to do the same but in Power Pivot since the data comes from an .atomsvc

 

I already added a column with the following code, but I want to add a line that, if the column [Date] has a day that is within the last 5 days, then it adds pending. Here is the code without that line.

 

New column is called [Result]

Column [Number] Is used to define if its approved or not, this one has priority no matter the others

Column [Date] Is used to define as "Pending" if its within the last 5 days

Else, it should be "Denied"

 

[Result]= SWITCH (
TRUE (),
'Test'[Number] = "X001", "Approved",
'Test'[Number] = "X002", "Approved",
'Test'[Number] = "X003", "Approved",
'Test'[Number] = "X004", "Approved",
'Test'[Number] = "X005", "Approved",
'Test'[Number] = "X006", "Approved",
'Test'[Number] = "X007", "Approved",
'Test'[Number] = "X008", "Approved",
'Test'[Number] = "X009", "Approved",
'Test'[Number] = "X010", "Approved",
"Denied"
)

 

My intention is that, unless is one of those number the result should be "Denied" with the exception of those with a number in the list I am adding, those should be "Approved" no matter if they have a date within the last 5 days.

@Ocasio27 

Perhaps

=IF('Test'[Number] IN {"X001","X002","X003","X004","X005","X006","X007","X008","X009","X010"},
      "Approved",
       IF(TODAY()-'Test'[Date]<=5,"Pending","Denied"))

@Sergei Baklan 

 

Amazing, thank you.

@Ocasio27 , you are welcome

@Sergei Baklan 

 

Sorry for the late reply but, how do you do that nice syntax? I use Visual studio code and is too plain simple.

 

Is there any "assistant" app to develop scripts in .m?

@Ocasio27 

Above concrete code is just in formula bar in Power Pivot, like Excel formulas in it's formula bar. Additionally I use DAX Studio , but that's not the code generator.