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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

Urgent : Filter row in matrix with measure value

Hello everyone,

 

Is it possible to filter elements of rows in matrix using a measure?

 

To explain : 

I have a "Smart parent entity" measure which returns the entity to be displayed according to the filters selected. when I select 

I would like to display the values ​​for the selected entity and its children (entite_parent = smart_entite_parent)

 

I have 2 tables : 

Table arbo 

Cmll_0-1629815793238.png

and table : "table donnees"

Cmll_1-1629815862148.png

region, departement and pays are calculated columns. they are used to create "smart entite parent"

 
SMART_ENTITE_PARENT =
IF (
    AND (
        NOT ( HASONEVALUE ( Arbo[Lib_niv_2] ) ),
        NOT ( HASONEVALUE ( Arbo[Lib_niv_1] ) )
    ),
    FIRSTNONBLANK ( Table_donnees[pays], Table_donnees[pays] ),
    IF (
        AND ( HASONEVALUE ( Arbo[Lib_niv_2] )NOT ( HASONEVALUE ( Arbo[Lib_niv_1] ) ) ),
        FIRSTNONBLANK ( Table_donnees[region], Table_donnees[region] ),
        FIRSTNONBLANK ( Table_donnees[Departement], Table_donnees[Departement] )
    )
)
 
I am forced to disable filtering between segments and matrix. in the following case I only want to display the France group :
Cmll_3-1629816643129.png

 

Here I would only to see Groupe Mayenne :

Cmll_4-1629816861904.png

 

The measure in matrix to see value is :

New Measure =
IF (
NOT ISINSCOPE ( Table_donnees[LIB_ENTITE] ),
CALCULATE (
SUM ( Table_donnees[VALEUR] ),
ALL ( Table_donnees[ENTITE_PARENT] ),
TREATAS ( VALUES ( Table_donnees[ENTITE_PARENT] ), Table_donnees[LIB_ENTITE] )
),
SUM ( Table_donnees[VALEUR] )
)
 
How can I filter only row where Entite_Parent = Smart_Entite_Parent ?
 
Thanks You for your help !
 
 
1 ACCEPTED SOLUTION
Anonymous
Not applicable

I found solution : I modified Smart_entite_parent. I replaced Haveonevalue by haveonefilter

So 

 

SMART_ENTITE_PARENT = 

IF (
AND (
NOT ( HASONEFILTER ( Arbo[Lib_niv_2] ) ),
NOT ( HASONEFILTER ( Arbo[Lib_niv_1] ) )
),
"FRANCE",
IF (
AND ( HASONEFILTER ( Arbo[Lib_niv_2] ), NOT ( HASONEFILTER ( Arbo[Lib_niv_1] ) ) ),
SELECTEDVALUE ( Arbo[Lib_niv_2] ),
SELECTEDVALUE ( Arbo[Lib_niv_1] )
)
)

 

and

 

New_Measure =
VAR entite_parent = [SMART_ENTITE_PARENT]
RETURN
IF (
NOT ISINSCOPE ( Table_donnees[LIB_ENTITE] ),
CALCULATE (
CALCULATE (
SUM ( Table_donnees[VALEUR] ),
FILTER ( Table_donnees, Table_donnees[LIB_ENTITE] = entite_parent )
),
ALL ( Table_donnees[ENTITE_PARENT] ),
TREATAS ( VALUES ( Table_donnees[ENTITE_PARENT] ), Table_donnees[LIB_ENTITE] )
),
CALCULATE (
SUM ( Table_donnees[VALEUR] ),
FILTER ( Table_donnees, Table_donnees[ENTITE_PARENT] = entite_parent )
)
)
 
Thanks @Greg_Deckler  for your help

View solution in original post

7 REPLIES 7
m3tr01d
Continued Contributor
Continued Contributor

hello @Anonymous,

what is the reason for keeping all the levels of the hirearchy in the Fact table (table de données)?

Can't you just keep the data at the lowest level of the hirearchy?

It seems bad practice to have the data set up like that in my opinion

Anonymous
Not applicable

Hi @m3tr01d , 

Users need to have this information, so I need to keep it 😞

How would you have configured data ?

 

Thank you for your help

Greg_Deckler
Community Champion
Community Champion

@Anonymous Yes, you want what I call a Complex Selector. The Complex Selector - Microsoft Power BI Community



Follow on LinkedIn
@ 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!:
DAX For Humans

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

Hi @Greg_Deckler Thanks for your reply but I don't see how the complex selector can act on the names of my lines. Could you help me on this? thank you very much.

@Anonymous In general, assuming a disconnected table for your slicer:

Complex Selector Measure =
  VAR __Group = SELECTEDVALUE('SlicerTable'[Column])
  VAR __CurrentGroup = MAX('Table'[Group])
RETURN
  IF(__Group=__CurrentGroup,1,0)

 



Follow on LinkedIn
@ 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!:
DAX For Humans

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

Hi @Greg_Deckler,

 

I tried this solution, but it doesn't work because SMART_ENTITE is a measure

 

I found the beginning of a pontential solution.

 

I modified the displayed dax measure :

 

New Measure =
VAR entite_parent = "GROUPE MAYENNE"
RETURN
IF (
NOT ISINSCOPE ( Table_donnees[LIB_ENTITE] ),
CALCULATE (
CALCULATE (
SUM ( Table_donnees[VALEUR] ),
FILTER ( Table_donnees, Table_donnees[LIB_ENTITE] = entite_parent )
),
ALL ( Table_donnees[ENTITE_PARENT] ),
TREATAS ( VALUES ( Table_donnees[ENTITE_PARENT] ), Table_donnees[LIB_ENTITE] )
),
CALCULATE (
SUM ( Table_donnees[VALEUR] ),
FILTER ( Table_donnees, Table_donnees[ENTITE_PARENT] = entite_parent )
)
)

 

and it shows me what I want to see for the "Groupe Mayenne"

Cmll_0-1629979610226.png

 

But now I would like to change the group "Groupe Mayenne"to SMART_entite so that it varies. But it doesn't work : 

 

Cmll_1-1629979758376.png

Do you know how I could do it?

 

Thanks

Anonymous
Not applicable

I found solution : I modified Smart_entite_parent. I replaced Haveonevalue by haveonefilter

So 

 

SMART_ENTITE_PARENT = 

IF (
AND (
NOT ( HASONEFILTER ( Arbo[Lib_niv_2] ) ),
NOT ( HASONEFILTER ( Arbo[Lib_niv_1] ) )
),
"FRANCE",
IF (
AND ( HASONEFILTER ( Arbo[Lib_niv_2] ), NOT ( HASONEFILTER ( Arbo[Lib_niv_1] ) ) ),
SELECTEDVALUE ( Arbo[Lib_niv_2] ),
SELECTEDVALUE ( Arbo[Lib_niv_1] )
)
)

 

and

 

New_Measure =
VAR entite_parent = [SMART_ENTITE_PARENT]
RETURN
IF (
NOT ISINSCOPE ( Table_donnees[LIB_ENTITE] ),
CALCULATE (
CALCULATE (
SUM ( Table_donnees[VALEUR] ),
FILTER ( Table_donnees, Table_donnees[LIB_ENTITE] = entite_parent )
),
ALL ( Table_donnees[ENTITE_PARENT] ),
TREATAS ( VALUES ( Table_donnees[ENTITE_PARENT] ), Table_donnees[LIB_ENTITE] )
),
CALCULATE (
SUM ( Table_donnees[VALEUR] ),
FILTER ( Table_donnees, Table_donnees[ENTITE_PARENT] = entite_parent )
)
)
 
Thanks @Greg_Deckler  for your help

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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