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