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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
jamieham
Helper II
Helper II

SWITCH

I'm trying to create a new column using the SWITCH function and I'm using the DAX formula below. The issue I have is if there is a blank for Gainline Prev the DAX formula is reading it as a 0 and adding Negative GL. How do I get it to ignore cells that are blank or is there a better way of doing it?

 

Gainline Prev                   Gainline
0                                      Negative GL
0                                      Negative GL
1                                      Positive GL
                                        Negative GL (dont want this to show)
0                                      Negative GL
1                                      PositiveGL
 
Gainline = SWITCH(TRUE(),default[Gainline Prev]=1,"Positive GL",default[Gainline Prev]=0,"Negative GL")
 
 
4 REPLIES 4
Anonymous
Not applicable

Hi @jamieham  ,

According to my understanding, you want to use switch() to create a new column and filter the blank row, right?

 

You could use the following formula:

Gainline =
VAR _blank =
    ISBLANK ( SELECTEDVALUE ( Default[Gainline Prev] ) )
RETURN
    SWITCH (
        TRUE (),
        SELECTEDVALUE ( Default[Gainline Prev] ) = 1
            && _blank = FALSE (), "Positive GL",
        SELECTEDVALUE ( Default[Gainline Prev] ) = 0
            && _blank = FALSE (), "Negative GL"
)

My visualization looks like this:

8.24.4.1.png

Is the result what you want? If you have any questions, please upload some data samples and expected output.

Please do mask sensitive data before uploading.

 

Best Regards,

Eyelyn Qin

I've attached a small sample of the data. I want to create a new column called Gainline that looks at Previous GL and adds Positive GL if the number is 1 and Negative GL if the number is 0. The issue I've had is that it's adding Negative GL if the cell is blank in Previous GL.
 
I want to add a column as per the attached table that is highlighted in red.
 
Hope that all makes sense.
 
Regards
 
Jamie
 
TeamTeam IDPlay NumSet NumPS TimestampPS EndstampHome TeamAway TeamMatch TimeHalfScore_AdvantageDescriptionMetresX_CoordX_Coord EndY_CoordY_Coord EndAction TypeAction ResultGainline NextGainline PrevGainline
Team 1500310372467250Team 1Team 2795627Ruck082080NAWon Outright10Negative GL
Team 1500410372577261Team 1Team 2800827Ruck0870440NAWon Outright11Positive GL
Team 1500510372657269Team 1Team 2801627Ruck0890580NAWon Outright11Positive GL
Team 3885011412Team 3Team 41010Possession1380936668Start Set 50m Restart RetainedEnd Set Own Lineout  
Team 388506244101Team 3Team 413110Possession392956853LineoutEnd Pen Won  
Team 4300024164178Team 3Team 425710Possession-154011Start Set Lineout StealEnd Scrum   
amitchandak
Super User
Super User

@jamieham ,

You can create a measure like

calculate([Meausre], filter(Table, not(isblank(Table[Gainline Prev]))))

 

Or you can use visual level or page filter Table[Gainline Prev] <> Blank ()

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

HI @jamieham 

 

In the filter pane for the Gainline Prev, you can say to ignore blank as below

pranit828_0-1598170404133.png

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.