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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

Filtering a grouped by table by slicer does not work

Hi,

 

I have a dataset like 

 

(table_x)

idplayer_idyear
1342020
2352020
3352021
4352021
5342021
6212021

 

I have grouped this table via DAX (with GROUPBY(...))  to:

 

(table_y)

player_idCOUNT(id)
211
342
353

 

 

After that I linked that table_x.player_id to table_y.player_id (1:n relationship) and built a slicer for the year.

 

If I now want to slice the data to year 2021 I thought I would end up like:

 

player_idCOUNT(id)
211
341
352

 

but the slicer has no effect. Why? 

1 ACCEPTED SOLUTION

Hi @Anonymous 

 

It some difficulty to do that, you can try this measure:

count(count(id)) =
VAR _1 =
    VALUES( Table_x[player_id] )
VAR _table_y =
    ADDCOLUMNS(
        _1,
        "count_id", COUNTROWS( FILTER( 'Table_x', [player_id] = EARLIER( Table_x[player_id] ) ) )
    )
VAR _group_table_y =
    SUMMARIZE(
        _table_y,
        [count_id],
        "count(count(id))", COUNTROWS( FILTER( _table_y, [count_id] = EARLIER( [count_id] ) ) )
    )
RETURN
    MAXX(
        FILTER( _group_table_y, [count_id] = SELECTEDVALUE( 'New Table'[Value] ) ),
        [count(count(id))]
    )

Before this measure, you need create new table in advance:

New Table = GENERATESERIES(1,COUNTROWS('Table_x'),1)

 

and the result :

vchenwuzmsft_0-1636963175619.png

I put my pbix file in the attachment you can refer

 


Best Regards

Community Support Team _ chenwu zhu

 

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

4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hi,

You do not need to create a table_y.  From table_x, create a Table visual and drag player_id to the row labels.  Create a slicer from the Year column and select 2021.  Write this measure

Measure = countrows(Data)

Hope this helps.

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-chenwuz-msft
Community Support
Community Support

Hi @Anonymous,

 

It strange that is it a data table or a visual table?

If data table in power bi, it won't work with slicer. The data table will be saved when you created. 

If a visual table, it is unnecessary to create a table_y, table_x is enough to reach that result.

first , drag 'table_x'[player_id] to table visual (don't summarize) and 'table_x'[id] (count). Then create a slicer with 'table_x'[year].

vchenwuzmsft_0-1636941883677.png

If create table_y is necessary and drag 'table_y'[player_id] will works with the relationship 1:mangy between them.

If I misunderstood you, please let me know.


Best Regards

Community Support Team _ chenwu zhu

 

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

Anonymous
Not applicable

Thank you for the answer. Sadly, i missed the last important point in my process. I do not only want to filter that table_y, I also want to group this table_y in a visual table like (for year: 2021): 

 

COUNT(id)COUNT(COUNT(id))
12
21

 

How many times does a player occur once, twice, ... in that year. 

 

Hi @Anonymous 

 

It some difficulty to do that, you can try this measure:

count(count(id)) =
VAR _1 =
    VALUES( Table_x[player_id] )
VAR _table_y =
    ADDCOLUMNS(
        _1,
        "count_id", COUNTROWS( FILTER( 'Table_x', [player_id] = EARLIER( Table_x[player_id] ) ) )
    )
VAR _group_table_y =
    SUMMARIZE(
        _table_y,
        [count_id],
        "count(count(id))", COUNTROWS( FILTER( _table_y, [count_id] = EARLIER( [count_id] ) ) )
    )
RETURN
    MAXX(
        FILTER( _group_table_y, [count_id] = SELECTEDVALUE( 'New Table'[Value] ) ),
        [count(count(id))]
    )

Before this measure, you need create new table in advance:

New Table = GENERATESERIES(1,COUNTROWS('Table_x'),1)

 

and the result :

vchenwuzmsft_0-1636963175619.png

I put my pbix file in the attachment you can refer

 


Best Regards

Community Support Team _ chenwu zhu

 

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

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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