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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Anonymous
Not applicable

If HasOneValue with && Return statement

 

Hello Power BI Super Users,

 

The data below is fake but the problem is real. 

 

October CoP File.pbix

 

My issue is that Excel Power Pivot does not use SelectedValue. I am having trouble adapting the return statement when I use HasOnveValue because I use &&.

 

Works Well in Power BI but not available in Excel

Masked Name =
VAR AttendanceValue = SELECTEDVALUE(Table1[Attendance Percent])
VAR GetName = SELECTEDVALUE(Table1[Student Full Name])
RETURN IF(AttendanceValue < 0.8 && AttendanceValue > 0, "*", GetName)
 
Get an error with HasOneValue
Masked Name1 =
VAR AttendanceValue = HASONEVALUE(Table1[Attendance Percent])
VAR GetName = HASONEVALUE(Table1[Student Full Name])
RETURN IF(HASONEVALUE(Table1[Attendance Percent]),
IF(VALUES(AttendanceValue < 0.8 && AttendanceValue > 0, "*", GetName)))
 
quipmaster_2-1698336363810.png

 


 

 

 

 

quipmaster_0-1698334003037.png

 

Here is a link to the PBIX file.

October CoP File.pbix

 

Appreciate any nudge. 

 

 

 

1 ACCEPTED SOLUTION
EylesIT
Resolver II
Resolver II

@Anonymous, please try changing the DAX expression of your [Masked Name1] measure to this:

 

 

Masked Name1 = 
VAR ovAttendanceValue = HASONEVALUE(Table1[Attendance Percent])
VAR AttendanceValue = VALUES(Table1[Attendance Percent])
VAR GetName = VALUES(Table1[Student Full Name])
RETURN 
    IF(
        ovAttendanceValue,
        IF(
            AttendanceValue < 0.8 && AttendanceValue > 0, "*", GetName
        )
    )

 

 

The error you were getting was because you were trying to pass in an expression to the VALUES function, but the VALUES function can only take a table or column. You were also trying to pass in more than one paramter when VALUES tables just 1 paramter.

 

View solution in original post

2 REPLIES 2
EylesIT
Resolver II
Resolver II

@Anonymous, please try changing the DAX expression of your [Masked Name1] measure to this:

 

 

Masked Name1 = 
VAR ovAttendanceValue = HASONEVALUE(Table1[Attendance Percent])
VAR AttendanceValue = VALUES(Table1[Attendance Percent])
VAR GetName = VALUES(Table1[Student Full Name])
RETURN 
    IF(
        ovAttendanceValue,
        IF(
            AttendanceValue < 0.8 && AttendanceValue > 0, "*", GetName
        )
    )

 

 

The error you were getting was because you were trying to pass in an expression to the VALUES function, but the VALUES function can only take a table or column. You were also trying to pass in more than one paramter when VALUES tables just 1 paramter.

 

Anonymous
Not applicable

@EylesIT - thank you!

 

I see what you mean. 

 

By using the nested IF statement, I could maintain the parameter rules and produce the intended output.

 

The if statement now has the parameter to choose either the hasonevalue or the alternative values.

 

Brilliant.

 

Thank you again.

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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