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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
MarkEvansHW
Helper II
Helper II

Slicer to select "group by" field in table

I have table like this:

quartermonthweekdatesales
2020-Q32020-092020-352020-09-01$14,43.85
2020-Q32020-082020-352020-08-31$32,432.32
2020-Q32020-082020-352020-08-30$986.45
2020-Q32020-082020-342020-08-29$11,344.00
...............

 

Here's an image of above table as it is displaying incorrectly in my browser:

MarkEvansHW_0-1600183367044.png

 

 

I have a slicer that allows the user to pick between "quarter", "month", week", and "date".

 

I'd like the resulting table to include a field (with no summary function) that groups by the appropriate period field based on the selection. In the example below, the user has selected "quarter":

 

Period (dynamic)sales (sum)
2020-Q3$983,324.23
2020-Q2 ...etc

 

Here's an image of above table:

MarkEvansHW_1-1600183415149.png

 

 

 

Perhaps further complicating this is that the source tables are "Direct Query". Thanks for your suggestions.

 

5 REPLIES 5
Anonymous
Not applicable

Hi @MarkEvansHW ,

 

Create a Category table for slicer. There is no relationship between two tables.

8.png

9.png

 

Then try this measure.

Period = 
SWITCH (
    SELECTEDVALUE ( Category[Category] ),
    "date", MAX ( 'Table'[date] ),
    "month", MAX ( 'Table'[month] ),
    "quarter", MAX ( 'Table'[quarter] ),
    "week", MAX ( 'Table'[week] )
)

result dynamic slicer.gif

 

You can check more details from here.

 

Best Regards,

Stephen Tao

 

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

I see - it is because in your fact table, the sales column is a text field and in the table visual you're showing it is "not summarized". I need for this to be a numeric field that sums in the solution. Thanks for the suggestion.

I'm trying to get it to summarize by the different levels. In your demo, the rows are not totalling for quarter, month, etc. There should be one row for the quarter, two rows for the months and so on.

 

I'm not actually sure how you're getting more than one row, tbh. When I implement similar solution, I get the MAX date for the given period type (day, week, month, etc) and it returns one row with that max date and the total sum of the other field.

Greg_Deckler
Community Champion
Community Champion

@MarkEvansHW In general, to use a measure in that way, you need to use the Disconnected Table Trick as this article demonstrates: https://community.powerbi.com/t5/Community-Blog/Solving-Attendance-with-the-Disconnected-Table-Trick...



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...

Yes, I have a measure that works that way using the disconnected table. However, I don't see any way to have a non-measure (not use SUM, MIN, MAX, etc) in a field in the resulting table. Thanks.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.