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

Slicer a visual table with a measure

Hey guys

I am trying to do something real simple, but I don't get it.

I have a dimention table with data from schools:

SCHOOL
A
B
C
D
E
F
G
H
I
J
K
L
M

 

And I also have a table with interaction with some of those schools:

interact table

SCHOOLdate
A08/03/2021
A10/02/2021
A10/10/2020
B31/05/2021
B20/05/2021
B08/03/2020
E14/03/2021
E08/01/2021
E17/08/2020
H22/02/2021
H17/05/2020

 

I created a measure that thells me if "@school" were contacted by year. It works pretty fine:

Interact measure =
IF(CALCULATE(
COUNT(Interact[school]),
filter(Interact, YEAR(Interacao[date]) = [YEAR_CR])
) > 0 , "interactec", "not interacted")
 
YEAR_CR is a measure based on year...
 
but the goal here is to create a slicer that can filter just the interactions or non interactions.
I tried something like theses videos:
and 
I'm not sure if this is the best way, but I tried to create an independent table 2x2:
FaceValue
Interact1
not interacted0

 

like those videos, but I had no sucess.
 
Please give me some suggestion!
Thank you
1 ACCEPTED SOLUTION

Hi @massotebernoull ,

You can create a measure as below to judge whether the school is interactive or not, please find the details in the attachment.

Flag = 
VAR _selyear =
    SELECTEDVALUE ( 'Year'[Year] )
VAR _selstatus =
    SELECTEDVALUE ( 'Table'[Status] )
VAR _selschool =
    SELECTEDVALUE ( 'School'[SCHOOL] )
VAR _cshools =
    CALCULATETABLE (
        VALUES ( 'interact'[SCHOOL] ),
        FILTER ( 'interact', YEAR ( 'interact'[date] ) = _selyear )
    )
VAR _except =
    EXCEPT ( VALUES ( 'School'[SCHOOL] ), _cshools )
RETURN
    IF (
        ( _selstatus = "Interact"
            && _selschool IN _cshools )
            || ( ( _selstatus = "not interacted"
            && _selschool IN _except ) ),
        1
    )

yingyinr_0-1648793438428.png

2. Apply a visual-level filter (Flag is 1) on the table visual as below screenshot

yingyinr_1-1648793502756.png

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
v-yiruan-msft
Community Support
Community Support

Hi @massotebernoull ,

I created a sample pbix file(see attachment), please check whether that is what you want. You can create a measure as below:

Countofschool = 
VAR _selyear =
    SELECTEDVALUE ( 'Year'[Year] )
VAR _selstatus =
    SELECTEDVALUE ( 'Table'[Status] )
RETURN
    IF (
        _selstatus = "Interact",
        CALCULATE (
            COUNT ( Interact[school] ),
            FILTER ( Interact, YEAR ( 'interact'[date] ) = _selyear )
        ),
        0
    )

yingyinr_0-1648627204006.png

If the above one is not your expected one, please provide some sample data (exclude sensitive data) and your expected result with backend logic and special examples. It is better if you can share a simiplified pbix file with me. You can refer the following thread to upload your file in the community. Thank you.

How to upload PBI in Community

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

It is almost that, your measures is really close to the ones I have. I need a slicer that tells me which school have interactions and wich schools have no interactions. Like this ilustration:

massotebernoull_0-1648758906980.png

 

is it possible?



Hi @massotebernoull ,

You can create a measure as below to judge whether the school is interactive or not, please find the details in the attachment.

Flag = 
VAR _selyear =
    SELECTEDVALUE ( 'Year'[Year] )
VAR _selstatus =
    SELECTEDVALUE ( 'Table'[Status] )
VAR _selschool =
    SELECTEDVALUE ( 'School'[SCHOOL] )
VAR _cshools =
    CALCULATETABLE (
        VALUES ( 'interact'[SCHOOL] ),
        FILTER ( 'interact', YEAR ( 'interact'[date] ) = _selyear )
    )
VAR _except =
    EXCEPT ( VALUES ( 'School'[SCHOOL] ), _cshools )
RETURN
    IF (
        ( _selstatus = "Interact"
            && _selschool IN _cshools )
            || ( ( _selstatus = "not interacted"
            && _selschool IN _except ) ),
        1
    )

yingyinr_0-1648793438428.png

2. Apply a visual-level filter (Flag is 1) on the table visual as below screenshot

yingyinr_1-1648793502756.png

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

this flag measure is amazing! thank you!!

amitchandak
Super User
Super User

@massotebernoull , Not very clear. You need dynamic segmentation to filter a measure

 

Dynamic Segmentation Bucketing Binning
https://community.powerbi.com/t5/Quick-Measures-Gallery/Dynamic-Segmentation-Bucketing-Binning/m-p/1...


Dynamic Segmentation, Bucketing or Binning: https://youtu.be/CuczXPj0N-k

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.