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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Aydeedglz
Helper V
Helper V

IF in DAX Studio

Hi I am trying to create a formula in DAX with IF but I keep getting errors in the bold area, can someone tell me what I am doing wrong?

 

This is what I am trying to create

f_GM/Customer = If(VALIDATED_PD[f_Category_1290] = "GM","GM",VALIDATED_PD[d_Customer_Name])

 

EVALUATE
ADDCOLUMNS(
VALUES( VALIDATED_PD[m_Group_Currency_Amount] ),
"Total Overdue", [a_TotalOverdue],
"Customer Name",
    VAR f_GM_CustomerPD = VALIDATED_PD[d_Customer_Name]
    RETURN
    IF ( f_GM_CustomerPD = "GM", "GM", VALIDATED_PD[d_Customer_Name])
)

8 REPLIES 8
jiaopengzi
Frequent Visitor

First make sure your business logic is correct.
1 Does your table `validated_pd` exist?
2 If your table exists, then your same [d_Customer_Name] will be allocated different [m_Group_Currency_Amount]
3 If the second item is satisfied, then you should still lack product information, or Say your "GM" needs to be distinct.

Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but please try something like below.

 

EVALUATE
    ADDCOLUMNS (
        SUMMARIZE (
            VALIDATED_PD,
            VALIDATED_PD[m_Group_Currency_Amount],
            VALIDATED_PD[d_Customer_Name]
        ),
        "Total Overdue", [a_TotalOverdue],
        "Customer Name",
            VAR f_GM_CustomerPD = VALIDATED_PD[d_Customer_Name]
            RETURN
                IF ( f_GM_CustomerPD = "GM", "GM", VALIDATED_PD[d_Customer_Name] )
    )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

I have this but the bold part doesn't work the "Customer Number" column, the rest does 

 

EVALUATE
    ADDCOLUMNS (
        SUMMARIZE (
            VALIDATED_PD,
            VALIDATED_PD[m_Group_Currency_Amount],
            VALIDATED_PD[d_Customer_Name]
        ),
        "Total Overdue", [a_TotalOverdue],
        "Customer Name",
            VAR f_GM_CustomerPD = VALIDATED_PD[d_Customer_Name]
            RETURN
                IF ( f_GM_CustomerPD = "GM", "GM", VALIDATED_PD[d_Customer_Name] ),
        "Customer Number",
            VAR f_GM_CustomerPD = VALIDATED_PD[d_Customer_Name]
            VAR f_GM_CustomerNumber = VALIDATED_PD[m_Customer_Number]
            RETURN
                IF ( f_GM_CustomerPD = "GM", BLANK(), f_GM_CustomerNumber )       
    )

 

Aydeedglz_0-1682346642331.png

 

Is it possible to add more than one IF? for example add to the same code  (last part of the code) (Code in DAX Studio is still running for last code)

 

f_GM/CustomerNo = IF(VALIDATED_PD[f_GM/Customer] = "GM", BLANK(), VALIDATED_PD[m_Customer_Number])

 

 

EVALUATE
    ADDCOLUMNS (
        SUMMARIZE (
            VALIDATED_PD,
            VALIDATED_PD[m_Group_Currency_Amount],
            VALIDATED_PD[d_Customer_Name]
        ),
        "Total Overdue", [a_TotalOverdue],
        "Customer Name",
            VAR f_GM_CustomerPD = VALIDATED_PD[d_Customer_Name]
            RETURN
                IF ( f_GM_CustomerPD = "GM", "GM", VALIDATED_PD[d_Customer_Name] ),
        "Customer Number",
            VAR f_GM_CustomerPD = VALIDATED_PD[d_Customer_Name]
            RETURN
                IF ( f_GM_CustomerPD = "GM", BLANK(), VALIDATED_PD[m_Customer_Number] )       
    )

 

 

Hi,

Please share your sample pbix file's link with how your expected outcome looks like.

Thanks.


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Hi, I cant share the data but this the code I have

 

In bold is the part that I am trying to add, above is the suggestion you made 

 

EVALUATE
    ADDCOLUMNS (
        SUMMARIZE (
            VALIDATED_PD,
            VALIDATED_PD[m_Group_Currency_Amount],
            VALIDATED_PD[d_Customer_Name]
        ),
        "Total Overdue", [a_TotalOverdue],
        "Customer Name",
            VAR f_GM_CustomerPD = VALIDATED_PD[d_Customer_Name]
            RETURN
                IF ( f_GM_CustomerPD = "GM", "GM", VALIDATED_PD[d_Customer_Name] ),
        "Customer Number",
            VAR f_GM_CustomerPD = VALIDATED_PD[d_Customer_Name]
            VAR f_GM_CustomerNumber = VALIDATED_PD[m_Customer_Number]
            RETURN
                IF ( f_GM_CustomerPD = "GM", BLANK(), f_GM_CustomerNumber )       
    )

 

And this the error:

Aydeedglz_0-1682112896433.png

 

Hi,

Sorry, this does not help to understand what/how is your expected outcome.
Please try something like below.

EVALUATE
table
    = ADDCOLUMNS (
        SUMMARIZE (
            VALIDATED_PD,
            VALIDATED_PD[m_Group_Currency_Amount],
            VALIDATED_PD[d_Customer_Name],
            VALIDATED_PD[m_Customer_Number]
        ),
        "Total Overdue", [a_TotalOverdue],
        "Customer Name",
            VAR f_GM_CustomerPD = VALIDATED_PD[d_Customer_Name]
            RETURN
                IF ( f_GM_CustomerPD = "GM", "GM", VALIDATED_PD[d_Customer_Name] ),
        "Customer Number",
            VAR f_GM_CustomerPD = VALIDATED_PD[d_Customer_Name]
            VAR f_GM_CustomerNumber = VALIDATED_PD[m_Customer_Number]
            RETURN
                IF ( f_GM_CustomerPD = "GM", BLANK (), f_GM_CustomerNumber )
    )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Hi, I cant share the data but this the code I have

 

In bold is the part that I am trying to add, above is the suggestion you made 

 

EVALUATE
    ADDCOLUMNS (
        SUMMARIZE (
            VALIDATED_PD,
            VALIDATED_PD[m_Group_Currency_Amount],
            VALIDATED_PD[d_Customer_Name]
        ),
        "Total Overdue", [a_TotalOverdue],
        "Customer Name",
            VAR f_GM_CustomerPD = VALIDATED_PD[d_Customer_Name]
            RETURN
                IF ( f_GM_CustomerPD = "GM", "GM", VALIDATED_PD[d_Customer_Name] ),
        "Customer Number",
            VAR f_GM_CustomerPD = VALIDATED_PD[d_Customer_Name]
            VAR f_GM_CustomerNumber = VALIDATED_PD[m_Customer_Number]
            RETURN
                IF ( f_GM_CustomerPD = "GM", BLANK(), f_GM_CustomerNumber )       
    )

 

And this the error:

Aydeedglz_0-1682112896433.png

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.