KARTHIKEYAN.A
KARTHIKEYAN.A

Reputation: 20078

How to produce result based on date with multiple conditions on power bi?

I'm trying to create validation based on date and some filters

my input table is

Status  Type    Date        PolicyNo 
PS      T607    01-01-2020  1002
PS      T608    01-01-2020  1002
CF      T646    01-01-2020  1002
PS      T607    04-01-2020  1003

My condition is

1) In a single day how to apply multiple conditions

2) My expected output is

Status  Type    Date        PolicyNo    Accept
PS      T607    01-01-2020  1002        0
PS      T608    01-01-2020  1002        0
CF      T646    01-01-2020  1002        0
PS      T607    04-01-2020  1003        1

EDIT:

Date
01-01-2020
01-01-2020
01-01-2020

PolicyNo
1002
1002
1002

Type : T697 with (T608 or T646)

T607 - compalsory so (&&)
T608 - Optional so (||)
T646 - Optional so 

(and)

Status : PS or CF 
PS - Optional so (||)
CF - Optional 

Conclude Condition: Same date (ex.01-01-2020) and Same PolicyNo(ex.1002) with (Type: T697 with (T608 or T646)) with (Status: PS or CF)

Upvotes: 0

Views: 950

Answers (1)

Strawberryshrub
Strawberryshrub

Reputation: 3389

Multiple conditions in M (Power Query) for a custom column:

= if [Date] = Date.From(DateTime.LocalNow()) and [Type] = "T607" and [PolicyNo] = 1003 then 1 else 0

And so on...

Note: The syntax has to be lower case, becaue M is case sensitive. You also can stack the if´s or use else if´s. You can also use a or condition.

You can do the same in DAX thou. With IF() and OR() functions (as new column):

= IF(OR([Date] = TODAY(), [Type] = "T607", [PolicyNo] = 1003), 1, 0)

EDIT

To your 4th comment. This logik works just fine (simplified sample):

enter image description here

Upvotes: 1

Related Questions