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
rkottap
Frequent Visitor

Create calculated field using MAXX with Multiple IF conditions

Hi Team,

 

I need to create a caalculated field using MAX & IF conditins if text is matching in a columns (Issue Type & Label) then add the text value for all the ID's in each row.
Logic:
IF "Issue Type"="Feature" & "Label" = "Pilot_Phd" THEN "Pilot"
EleseIF
IF "Issue Type"="Feature" & "Label" = "Testing" THEN "Test"
ElseIF
IF "Issue Type"="Feature" & "Label" = "Check" THEN "Control"
Else
"BAU" ENDIF

Please see the attached screenshot for expected "Output" in column "D".

 

I have tried below DAX, but it's not giving the result for all the rows.

 

Please giude me to resolve this issue.

 

DAX:

Output =

VAR MaxProject =

SWITCH(

TableName [Issue Type]="Feature" && TableName [Label]="Pilot_Phd", "Pilot",

TableName [Issue Type]="Feature" && TableName [Label]="Testing", "Test",

TableName[Issue Type]="Feature" && TableName [Label]="Check", "Control",


TRUE(),

RETURN


BLANK())

IF(TableName [ID]=TableName[ID], CALCULATE (MAXX (

FILTER (TableName, TableName [ID]=TableName[ID]), MaxProject)), "BAU")


Screenshot:
DAX_MAXX with IF conditions.jpeg

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @rkottap 

Please try

Output =
VAR CurrentIDTable =
CALCULATETABLE ( TableName, ALLEXCEPT ( TableName, TableName[ID] ) )
VAR FeatureTypeRecord =
FILTER ( TableName, TableName[Issue Type] = "Feature" )
VAR FeatureLabel =
MAXX ( FeatureTypeRecord, TableName[Label] )
VAR Result =
SWITCH (
FeatureLable,
"Pilot_Phd", "Pilot",
"Testing", "Test",
"Check", "Control",
"BAU"
)
RETURN
Result

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hi @rkottap ,

 

Thanks to @tamerj1  for the reply, please allow me to provide another insight:


1. Create a calculated column.

 

Output =
VAR MaxProject = SWITCH(
TRUE(),
'Table'[Issue Type] = "Feature" && 'Table'[Label] = "Pilot_Phd", "Pilot",
'Table'[Issue Type] = "Feature" && 'Table'[Label] = "Testing", "Test",
'Table'[Issue Type] = "Feature" && 'Table'[Label] = "Check", "Control")
RETURN

MaxProject

 

2. Create the calculated column again to get the final result.

Column =
VAR _out = CALCULATE(MAX('Table'[Output]),FILTER(ALL('Table'),'Table'[ID] = EARLIER('Table'[ID])))
RETURN
IF(_out = BLANK(),"BAU",_out)

 

3. You can click the little eye next to the column name to hide unnecessary columns.

vkaiyuemsft_0-1714463012174.png

 

vkaiyuemsft_1-1714463012175.png

If your Current Period does not refer to this, please clarify in a follow-up reply.

 

Best Regards,

Clara Gong

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

tamerj1
Super User
Super User

Hi @rkottap 

Please try

Output =
VAR CurrentIDTable =
CALCULATETABLE ( TableName, ALLEXCEPT ( TableName, TableName[ID] ) )
VAR FeatureTypeRecord =
FILTER ( TableName, TableName[Issue Type] = "Feature" )
VAR FeatureLabel =
MAXX ( FeatureTypeRecord, TableName[Label] )
VAR Result =
SWITCH (
FeatureLable,
"Pilot_Phd", "Pilot",
"Testing", "Test",
"Check", "Control",
"BAU"
)
RETURN
Result

I have added the VAR name in the second VAR line, where Table name is used;

Now it's working fine, Thank you for your help 🙂

Output =
VAR CurrentIDTable =
CALCULATETABLE ( TableName, ALLEXCEPT ( TableName, TableName[ID] ) )
VAR FeatureTypeRecord =
FILTER ( CurrentIDTable , TableName[Issue Type] = "Feature" )
VAR FeatureLabel =
MAXX ( FeatureTypeRecord, TableName[Label] )
VAR Result =
SWITCH (
FeatureLable,
"Pilot_Phd", "Pilot",
"Testing", "Test",
"Check", "Control",
"BAU"
)
RETURN
Result

@rkottap 
You are right. That was a typo mistake.

Hi @tamerj1 
Thank you for your response.

 

It's not returning the values as per the conditions. 
It's adding text "BAU" for all the rows in table. 

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.