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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
danb27
Regular Visitor

create a table based on a query, keeping filters on page

Say I have Query1, which looks like this:

date, origin, type, cnt 
5/1/2019, A, A, 6
4/29/2019, B, A, 6
4/29/2019, C, B, 3

And I have three filters on the report where users can define a date range, what origins, and types to consider.

Now I need to create a second table (DailyFiltered) that looks like this when no filters are applied:

date, filteredCnt
5/1/2019, 6
4/29/2019, 9

While considering what the user defines in the report filters. For example, if the user were to select only type A, then Daily Filtered would instead look like this:

date, filteredCnt
5/1/2019, 6
4/29/2019, 6

Currently, I have:

Daily Filtered = summarize(keepfilters(Query1), Query1[date], 
    "filteredCnt", sum(Query1[cnt]))

And I have Query1 and Daily Filtered joined on date, many to one, cross filter direction = Both.

The second table is only being filtered by the date filter for Query1. Not sure where I went wrong.

6 REPLIES 6
Ashish_Mathur
Super User
Super User

Hi,

Just drag Date to your visual and then use this measure

=SUM(Data[Cnt])

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

So then follow up question: if I wanted to get the 90th percentile of that measure, how would I do that? 


@danb27 wrote:

So then follow up question: if I wanted to get the 90th percentile of that measure, how would I do that? 


With something like the following using the Percentilex.inc function:

 

90th Percentile = PERCENTILEX.INC( Values( Query1[date] ), CALCULATE(SUM(Query1[cnt])), 0.9 )

d_gosbell
Super User
Super User

The approach of creating a new calculated table will not work. Calculated tables are evaluated when the data is refreshed, they are not re-calculated any time a filter is changed.

 

But you don't need a separate table for this, you could just create a measure to do the daily totals.

 

eg.

 

Daily Cnt = CALCULATE( SUM( Query1[Cnt] ), ALL( Query1 ), VALUES( Query1[date] ) )

When I try to plot this in a histogram it doesn't work. I am hoping to have a histogram where the X axis is ranges of the sum of all counts and the y axis is the number of dates that fall into each range. Thank you for all the help so far


@danb27 wrote:

When I try to plot this in a histogram it doesn't work. I am hoping to have a histogram where the X axis is ranges of the sum of all counts and the y axis is the number of dates that fall into each range. Thank you for all the help so far


That's a completely new requirement. You need to generate a column for the "ranges of sums" to put on the x-axis and create a new measure that counts the dates. I answered a similar question a few weeks ago here https://community.powerbi.com/t5/Desktop/Double-grouping/td-p/672757 you should be able to use the same technique here.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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