Forum Discussion

jhimelic's avatar
jhimelic
Frequent Visitor
6 years ago
Solved

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 🙂

 

  • jhimelic's avatar
    jhimelic
    6 years ago

    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. 

3 Replies