cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
thale
Helper II
Helper II

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 @thale 

 

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 @thale,

 

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.

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 @thale 

 

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
June 2022 update 768X460.jpg

Check it out!

Click here to read more about the June 2022 updates!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power BI Dev Camp Session 23 768x460.jpg

Check it Out!

Mark your calendars and join us on Thursday, June 30 at 11a PDT for a great session with Ted Pattison!

June 20 episode 7 with aka link 768x460.jpg

The Power BI Community Show

Join us on June 20 at 11 am PDT when Kim Manis shares the latest on Azure Synapse analytics, the Microsoft Intelligent Data Platform, and notable Power BI Updates from Microsoft Build 2022.

Top Solution Authors
Top Kudoed Authors