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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
Anonymous
Not applicable

Dax Returned statement Help

ok so the top had of my DAx is running fine as it should but then I get down to the return part I am running into issues. I am trying to have it print off a 2,1,-1or -2 to based off what it get from "latest status" which hold two values. I need hep because I need to change itto catch certain combos like if "latest status" is -2,2 & 2,-2 & 2 ,2 & 2,1 and so on. As long as there is one 2 present it print 2 and same with 1 also lons as 1 is the greatest value it print 1 Examples if its 1,-1& -1,1 &1,-2 & -2,1 it prints 1 and for combos like  -1,-1 it print -1 and for -2 -2 it prints -2.  tried switching the and to or but it let all combos through. 
 
RETURN
IF(
FIND("2", LatestStatus, 1, 0) > 0 && FIND("-2", LatestStatus, 1, 0) = 0, "2",
IF(
FIND("1", LatestStatus, 1, 0) > 0 && FIND("-1", LatestStatus, 1, 0) = 0, "1",
IF(
FIND("-2", LatestStatus, 1, 0) > 0, "-2",
IF(
FIND("-1", LatestStatus, 1, 0) > 0, "-1",
"BLANK"
)
)
)
)
1 ACCEPTED SOLUTION
xifeng_L
Super User
Super User

Hi @Anonymous ,

 

You can refer to below method.

 

xifeng_L_2-1716611265024.png

 

RETURN = 
VAR LatestStatus = 'Table'[Latest Status]
VAR SplitPositions = 
    UNION(
        SELECTCOLUMNS({0},"Position",[Value]),
        DISTINCT(FILTER(SELECTCOLUMNS(GENERATESERIES(1,LEN(LatestStatus )),"Position",FIND(",",LatestStatus ,[Value],BLANK())),[Position]<>BLANK())),
        {LEN(LatestStatus )+1}
    )
VAR SplitPosition_AddIndex = ADDCOLUMNS(SplitPositions,"Index",RANKX(SplitPositions,[Position],,1))
VAR NumList = 
    SELECTCOLUMNS(
        GENERATESERIES(1,COUNTROWS(SplitPositions)-1),
        "Num",
            VAR Start_ = SUMMARIZE(FILTER(SplitPosition_AddIndex,[Index]=[Value]),[Position])+1
            VAR End_ = SUMMARIZE(FILTER(SplitPosition_AddIndex,[Index]=[Value]+1),[Position])
            RETURN
            MID(LatestStatus ,Start_,End_-Start_)*1
    )
RETURN
MAXX(NumList,[Num])

 

 

Demo - Dax Returned statement Help.pbix

 

 

Did I answer your question? If yes, pls mark my post as a solution and appreciate your Kudos !

 

Thank you~

 

 

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

So sorryfor not responding, I started working on something else and just did not get an update notification from my posted question so I'll tries methods now and get back to everyone who responded to help. 

xifeng_L
Super User
Super User

Hi @Anonymous ,

 

You can refer to below method.

 

xifeng_L_2-1716611265024.png

 

RETURN = 
VAR LatestStatus = 'Table'[Latest Status]
VAR SplitPositions = 
    UNION(
        SELECTCOLUMNS({0},"Position",[Value]),
        DISTINCT(FILTER(SELECTCOLUMNS(GENERATESERIES(1,LEN(LatestStatus )),"Position",FIND(",",LatestStatus ,[Value],BLANK())),[Position]<>BLANK())),
        {LEN(LatestStatus )+1}
    )
VAR SplitPosition_AddIndex = ADDCOLUMNS(SplitPositions,"Index",RANKX(SplitPositions,[Position],,1))
VAR NumList = 
    SELECTCOLUMNS(
        GENERATESERIES(1,COUNTROWS(SplitPositions)-1),
        "Num",
            VAR Start_ = SUMMARIZE(FILTER(SplitPosition_AddIndex,[Index]=[Value]),[Position])+1
            VAR End_ = SUMMARIZE(FILTER(SplitPosition_AddIndex,[Index]=[Value]+1),[Position])
            RETURN
            MID(LatestStatus ,Start_,End_-Start_)*1
    )
RETURN
MAXX(NumList,[Num])

 

 

Demo - Dax Returned statement Help.pbix

 

 

Did I answer your question? If yes, pls mark my post as a solution and appreciate your Kudos !

 

Thank you~

 

 

gmsamborn
Super User
Super User

Hi @Anonymous 

 

Would this help?

 

RETURN
	IF(
		FIND( "-2", LatestStatus, 1, 0 ) > 0,
		"-2",
		IF(
			FIND( "-1", LatestStatus, 1, 0 ) > 0,
			"-1",
			IF(
				FIND( "2", LatestStatus, 1, 0 ) > 0,
				"2",
				IF(
					FIND( "1", LatestStatus, 1, 0 ) > 0,
					"1",
					"BLANK"
				)
			)
		)
	)

 



Proud to be a Super User!

daxformatter.com makes life EASIER!

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.