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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Accy
Regular Visitor

Show column if only one value And that value is not Null or String

New to Power bi and need some help...

 

I got a measure that I only want to show if another column only contains one value and that value is not null or not like “String ABC”.

 

I’ve figured out how to show when it’s only one value:

New Column = IF(HASONEVALUE(ADServers[OperatingSystem]);"LastLogon: " & VALUES(ADServers[LastLogonDate]);"")

 

The problem is that now it can return just “LastLogon: “. I would like it to return empty (“”).

1 ACCEPTED SOLUTION
TomMartens
Super User
Super User

Hey,

 

maybe this DAX creates the measure you are looking for:

Measure = 
IF(
    HASONEVALUE(Table1[a column])
    , var theSelectedValue = SELECTEDVALUE(Table1[a column], "")
    return
        IF(
            OR(ISBLANK(theSelectedValue), theSelectedValue = "String ABC")
            , "the wrong values are selected" -- replace with empty string
            , theSelectedValue
        )
    ,"nothing is selected single value selected" -- replace with empty string
)


Hopefully this provides what you are looking for.

Regards,

Tom

 

 



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

View solution in original post

2 REPLIES 2
TomMartens
Super User
Super User

Hey,

 

maybe this DAX creates the measure you are looking for:

Measure = 
IF(
    HASONEVALUE(Table1[a column])
    , var theSelectedValue = SELECTEDVALUE(Table1[a column], "")
    return
        IF(
            OR(ISBLANK(theSelectedValue), theSelectedValue = "String ABC")
            , "the wrong values are selected" -- replace with empty string
            , theSelectedValue
        )
    ,"nothing is selected single value selected" -- replace with empty string
)


Hopefully this provides what you are looking for.

Regards,

Tom

 

 



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

That looks promising TomMartens! There is one problem, though…

 

Now my measure looks like this:

HiddenPRTGSensors_Uptime = IF(

    HASONEVALUE(PRTGDevices[Active])

    ; var theSelectedValue = FORMAT(AVERAGEX(PRTGSensors; PRTGSensors[Uptime]); "0.00")

    return

        IF(

            OR(ISBLANK(theSelectedValue); theSelectedValue = "NA")

            ; "" -- replace with empty string

            ; "Uptime: " & theSelectedValue & "%"

        )

    ;"" -- replace with empty string

)

 

When PRTGDevices[Active] = NA and PRTGSensors[Uptime] = Null it returns “Uptime %”

FYI, PRTGSensors[Uptime] may contain null, one or more values. 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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