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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
akito
Frequent Visitor

IF with multiple condition (more than 3) + DAX formula help needed

Hi Masters,

 

I am pretty new in DAX as well as in Power BI. 

 

Please see below snapshots : Basically I am trying to mark/tag my projects with specific words based on their approval statuses. I have 3 types of approvals and if all have "Yes" I would like to write and tag that project as "F-R-W" whcih stands for "Finance - Risk  - Workstream". I am able to do this in excel table where I have one table. However now I am trying to do this in database where I have many tables with relationships. It is not only question around multiple AND conditon with IF, it is also how I can do this in  database where I have multiple tables . Please check snapshots and i hope you will understand what I am trying to do. 

 

Excel formula that I used to use:

akito_1-1652864001447.png

In DAX  - what I am trying to do

akito_0-1652863987458.png

Expected DAX outcome:

akito_2-1652864062605.png

 

Regards,

Akito

1 ACCEPTED SOLUTION
v-cgao-msft
Community Support
Community Support

Hi @akito ,

 

Try this measure.

Required Approvals = 
VAR _finance_approvals =
    MAX ( 'Initiative Pending Approval'[Finance Approvals] )
VAR _risk_approvals =
    MAX ( 'Initiative Pending Approval'[Risk Approvals] )
VAR _workstream_approvals =
    MAX ( 'Initiative Pending Approval'[Workstream Approvals] )
RETURN
    SWITCH (
        TRUE (),
        _finance_approvals = "Yes"
            && _risk_approvals = "Yes"
            && _workstream_approvals = "Yes", "F-R-W",
        _finance_approvals = "Yes"
            && _risk_approvals = "Yes"
            && _workstream_approvals = "", "F-R",
        _finance_approvals = "Yes"
            && _risk_approvals = ""
            && _workstream_approvals = "", "F"
    )

vcgaomsft_0-1653298201200.png

Attached PBIX file for reference.

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

View solution in original post

3 REPLIES 3
akito
Frequent Visitor

Thanks a lot @v-cgao-msft  - this worked very well. 

v-cgao-msft
Community Support
Community Support

Hi @akito ,

 

Try this measure.

Required Approvals = 
VAR _finance_approvals =
    MAX ( 'Initiative Pending Approval'[Finance Approvals] )
VAR _risk_approvals =
    MAX ( 'Initiative Pending Approval'[Risk Approvals] )
VAR _workstream_approvals =
    MAX ( 'Initiative Pending Approval'[Workstream Approvals] )
RETURN
    SWITCH (
        TRUE (),
        _finance_approvals = "Yes"
            && _risk_approvals = "Yes"
            && _workstream_approvals = "Yes", "F-R-W",
        _finance_approvals = "Yes"
            && _risk_approvals = "Yes"
            && _workstream_approvals = "", "F-R",
        _finance_approvals = "Yes"
            && _risk_approvals = ""
            && _workstream_approvals = "", "F"
    )

vcgaomsft_0-1653298201200.png

Attached PBIX file for reference.

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

@v-cgao-msft hey nice one ..

I am also working and struggling to get one of the IF logic conditions as below :

 

Logic :

if "Are there any changes between SOW Agreed Scope & Revised Scope?" is Yes and "Is the devaition between SOW Agreed scope and revised scope has major deviation?" is Yes --> Red

              if "Is the CR raised?" is yes or No then keep it Red

              if "Is the CR raised?" is yes and "Is the CR approved?" is No then keep it Red

              if "Is the CR raised?" is yes and "Is the CR approved?" is yes then change it to Green

if "Are there any changes between SOW Agreed Scope & Revised Scope?" is Yes and "Is the devaition between SOW Agreed scope and revised scope has major deviation?" is No --> Amber

              if "Is the CR raised?" is yes or No then keep it Amber

              if "Is the CR raised?" is yes and "Is the CR approved?" is No then keep it Amber

              if "Is the CR raised?" is yes and "Is the CR approved?" is yes then change it to Green

All the above questions are already available in the Sharepoint list source , based on the above logics I have to create a column for the accounts like below .

 

dinesharivalaga_0-1725864138516.png

I have tried this below DAX but not working as expected.

 

Scope logic=
IF (
    [ArethereanychangesbetweenSOWAgre] = "Yes" &&
        [IsthedevaitionbetweenSOWAgreedsc] = "Yes",
        "Red",
        IF (
            [istheCRraised?] = "Yes" &&
                [IstheCRapproved?] = "No",
                "Red",
    IF (
    [ArethereanychangesbetweenSOWAgre] = "Yes" &&
        [IsthedevaitionbetweenSOWAgreedsc] = "No",
        "Amber",
    IF (
        [istheCRraised?] = "Yes" &&
            [IstheCRapproved?] = "No",
            "Amber",
            "Green"
        )
    )))

Can you please help to solve this DAX ?..

 

Thanks

DK

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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