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
xuri
Frequent Visitor

HASONEVALUE-Function shall only be working when a filter is set for a column in the query editor

Hello,

I'm struggling with a filtering issue for days and at the moment I'm not sure if it is feasible:

I want to display a warning by means of the IF-function, which vanishes if the Column "MyChoice" is filtered for one value in the query editor. For more than one value in the query editor's filter for "MyChoice" and for any active filter in the report, the warning shall be displayed. With the following function, I get something similar, but I cannot make the filter only valid for filters in the query editor.


IF(HASONEVALUE('MyTable'[MyChoice]); ""; "WARNING: The calculations are only valid if you have selected one value via the query editor! Please select one value!")

Is this possible or is there another alternative to achieve this kind of filter? I have the feeling that Power BI does not distinguish between filtering on report level or in the query editor and thus cannot be separated.

Thanks in advance, any hints and tricks will be appreciated!
xuri

1 ACCEPTED SOLUTION
TomMartens
Super User
Super User

Hey,

 

I'm not sure what you are referring to, if you mention query editor.

 

If you mean the query editor where you access your source data and prepare the data for its usage in the Power BI data model, you can not hand down a slicer selection to the query editor:

Basically there are these layers of interaction

 

Interaction Layer 1: Source Data (Data Layer 1) -> Power Query -> Data Model (Data Layer 2)
Interaction Layer 2: Data Model (Data Layer 2) -> Relationships / Calculated Columns / Measures -> Refined Data Model (Data Layer 3)

 

Basically there are just these possibilities for a user to interact with the different Layers of Interaction:

IL1: Query Parameter

IL2: Slicer Selection / Cross Filtering / What-if parameter (since the August 2017 release).

 

If I'm getting you wrong, and your were referring to this DAX thing, you have to encapsulate each of your measures like this 
theMeasure = 
IF(HASONEVALUE( ... )
,the calcualtion of the measure
,the warning
)

 

Hope this helps somehow

 



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,

 

I'm not sure what you are referring to, if you mention query editor.

 

If you mean the query editor where you access your source data and prepare the data for its usage in the Power BI data model, you can not hand down a slicer selection to the query editor:

Basically there are these layers of interaction

 

Interaction Layer 1: Source Data (Data Layer 1) -> Power Query -> Data Model (Data Layer 2)
Interaction Layer 2: Data Model (Data Layer 2) -> Relationships / Calculated Columns / Measures -> Refined Data Model (Data Layer 3)

 

Basically there are just these possibilities for a user to interact with the different Layers of Interaction:

IL1: Query Parameter

IL2: Slicer Selection / Cross Filtering / What-if parameter (since the August 2017 release).

 

If I'm getting you wrong, and your were referring to this DAX thing, you have to encapsulate each of your measures like this 
theMeasure = 
IF(HASONEVALUE( ... )
,the calcualtion of the measure
,the warning
)

 

Hope this helps somehow

 



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

@TomMartens: Thanks for your quick response! Yes, I actually meant the query editor where you can access your source data. So my assumption was correct, that it is not possible. I will start a new topic with my actual problem since this would be an extension of my question to which you have already given me the answer. 

 

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.