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
jhimelic
Frequent Visitor

filtering a calculated / temporary table to generate a histogram

hello all

 

i have created a variable that stores a table which i then use to calculate some parameters that arent native in my raw tables. up until now, all of my measures referencing this temporary table have been working well. the trouble comes when i try to filter these calculated data points with some criteria in order to create a histogram on the data. 

 

everything i have learned about calculate and filtering doesnt appear to be working. I have tried multiple approaches and they have both failed. 

 

i have defined separate measures for the upper and lower ranges of each bin, which i am using to define the intervals ([MinBoundary] and [MaxBoundary]) from a separate table (bintable). both appear to be flowing through as expected. 

 

Method 1:

=

VAR Temp_Table =

SUMMARIZE(original table, original table [Sim_Run], "new column name", expression)

RETURN

calculate(countrows(Temp_Table,FILTER(Temp_Table,[new column name] >= bintable[Min_Boundary] && [new column name] < bintable[Max_Boundary]))

 

Method 2:

=

VAR Temp_Table =

SUMMARIZE(original table, original table [Sim_Run], "new column name", expression)


VAR Temp_Table_II =

CALCULATETABLE(Temp_Table,filter(Temp_Table,[new column name]>=bintable[Min_Boundary]) && [new column name]<bintable[Max_Boundary])

RETURN

CALCULATE(COUNTROWS(Temp_Table_II))

 

as you can see below, neither methods properly categorizes each row value of "new column name" located in the temporary table. in the example below, i have 3 sims (i.e. final values) that i want sorted in the appropriate bin. i am expecting to see each sim show up only once in one of the mutually exclusive bins. however, power pivot appears to not acknowledge any of the filters that i apply. how rude 🙂

 

image.png

1 ACCEPTED SOLUTION

thank you for referencing the helpful series of articles. after going through them and working on this issue some more, i was able to stumble across a working solution: 

 

the tweak i made that worked is the following

 

=

VAR Temp_Table =

SUMMARIZE(original table, original table [property i am using to count across], "new column name", expression)

RETURN

 

countrows(filter(Temp_Table,FILTER(Temp_Table,[new column name] >= bintable[Min_Boundary] && [new column name] < bintable[Max_Boundary]))

 

this small tweak was all i needed. 

View solution in original post

3 REPLIES 3

thank you for referencing the helpful series of articles. after going through them and working on this issue some more, i was able to stumble across a working solution: 

 

the tweak i made that worked is the following

 

=

VAR Temp_Table =

SUMMARIZE(original table, original table [property i am using to count across], "new column name", expression)

RETURN

 

countrows(filter(Temp_Table,FILTER(Temp_Table,[new column name] >= bintable[Min_Boundary] && [new column name] < bintable[Max_Boundary]))

 

this small tweak was all i needed. 

Ashish_Mathur
Super User
Super User

Hi,

Your question is not clear.  Share some data, describe the question and show the expected result.


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

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.