Forum Discussion
IF in DAX Studio
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] )
)
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)
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] )
)
- Jihwan_Kim3 years ago
Super User
Hi,
Please share your sample pbix file's link with how your expected outcome looks like.
Thanks.
- Anonymous3 years agoNot applicable
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:
- Anonymous3 years agoNot applicable
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:
- Jihwan_Kim3 years ago
Super User
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 ) )