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
Anonymous
Not applicable

Passing a BLANK() in a measure based on a boolean

I have a measure, where depending on the boolean results from another measure I either want to return a value or BLANK(). The measure is going to be used to drive conditional formatting and the only way I can think to filter out certain rows from being formatted is to pass a blank in that given row's context. The row has the boolean value, which is passed via a "helper" measure. The value piece works fine, it currently fails on the evaluation of the boolean. Suggestions? What am I missing?

 

 

Deviation Calc =
//take the Avg Category Deviation and compare it to the current row value for conditional formatting

VAR CurrentVal = [% of Bnch Growth by Cat] //current row's value, % of Benchmark
VAR PercRemainder = [Avg Cat Deviation Value] 

VAR Diff = ABS(PercRemainder - CurrentVal)
VAR IsDependent = [CategoryIsDependent]


VAR __CALC = IF( Diff > [Allowed Progam % Deviation], [Allowed Progam % Deviation], Diff)
VAR RESULT = IF(IsDependent, __CALC, BLANK())

RETURN
 RESULT

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Ok, so further troubleshooting pointed to the fact that the underlying measure [IsDependent] works fine in a Table, but not a Matrix... (surprise...).

 

Have adjusted [IsDependent] to work properly in a Matrix, but now new question, why does "BLANK()" get passed as a "FALSE", if I substitute a text string for "BLANK()" then the text string shows in the summary rows of the matrix as expected.

CategoryIsDependent = 
VAR __Dependence = IF(HASONEVALUE( 'prog Space Categories'[Dependent] ), VALUES('prog Space Categories'[Dependent]), BLANK() )
//solves for if the current row context represents a Dependent Space Cateogry.
RETURN
    __Dependence

View solution in original post

3 REPLIES 3
Greg_Deckler
Super User
Super User

Not sure I follow this, what is [CategoryisDependent]? Is that a measure? What data type is it? Where is it failing? What error do you get?

 

Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Well, I had one typo on my code (Corrected above) however, that was a clerical error on my part when making the post.

 

[CategoryIsDependent] is a measure which in this context, would appear to be returning multiple values, even though it works fine when applied directly to a visual (table).

 

image.png

 

CategoryIsDependent = 
VAR __Dependence = VALUES('prog Space Categories'[Dependent])
//solves for if the current row context represents a Dependent Space Cateogry.
RETURN
    __Dependence

 

I assumed that since it was working in a visual context, that I would be able to drop it into another measure without issue. Apparently not!

Anonymous
Not applicable

Ok, so further troubleshooting pointed to the fact that the underlying measure [IsDependent] works fine in a Table, but not a Matrix... (surprise...).

 

Have adjusted [IsDependent] to work properly in a Matrix, but now new question, why does "BLANK()" get passed as a "FALSE", if I substitute a text string for "BLANK()" then the text string shows in the summary rows of the matrix as expected.

CategoryIsDependent = 
VAR __Dependence = IF(HASONEVALUE( 'prog Space Categories'[Dependent] ), VALUES('prog Space Categories'[Dependent]), BLANK() )
//solves for if the current row context represents a Dependent Space Cateogry.
RETURN
    __Dependence

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.

Top Solution Authors