cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
New Member

Returning a table with calculated Top N

Hi everyone, 

 

I have created a new table with a new column "Rand": 

TableWithRand =
ADDCOLUMNS ( "Table1", "Rand", RAND() )
 
Originally I also added the following: 
VAR SampleSize = 10
VAR SampleSize5=  .05 *( COUNTROWS(TableWithRand)
VAR MySampleSize = IF(SampleSize5 > 10, SampleSize5, SampleSize)
RETURN
TOPN(MySampleSize, TableWithRand, [Rand])
 
However I now have to filter the table by date through a slicer and determine the sample size based on the filtered results. How can I achieve the result of the code above after the new table has been created and the user has selected the date range? 
 
 
1 ACCEPTED SOLUTION

Accepted Solutions
Super User III
Super User III

HI @annag815 ,

 

Tables in PBI are STATIC. ALWAYS. They're recalculated when data is refreshed. Table variables used in measures are dynamic but they are gone as soon as the measure has returned its value.

 

Slicers cannot be used in Tables.  They can, however, be used in measures.

Slicers are Filters,  use filter context.  Filters can change dynamically based on what is selected, and how filter interactions are defined.  Since measures are dynamic fields calculated on demand, they can leverage this filter context to shape results.

Tables are populated once at data refresh, and don't update again.  If you change interactions, change slicers, the underlying row context and any calculations performed at load would be unaffected.

 

 

Regards,

Harsh Nathani

Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

 

 

View solution in original post

2 REPLIES 2
Super User III
Super User III

HI @annag815 ,

 

Tables in PBI are STATIC. ALWAYS. They're recalculated when data is refreshed. Table variables used in measures are dynamic but they are gone as soon as the measure has returned its value.

 

Slicers cannot be used in Tables.  They can, however, be used in measures.

Slicers are Filters,  use filter context.  Filters can change dynamically based on what is selected, and how filter interactions are defined.  Since measures are dynamic fields calculated on demand, they can leverage this filter context to shape results.

Tables are populated once at data refresh, and don't update again.  If you change interactions, change slicers, the underlying row context and any calculations performed at load would be unaffected.

 

 

Regards,

Harsh Nathani

Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

 

 

View solution in original post

Community Support
Community Support

hi  @annag815 

First, you should know that:

1. Calculation column/table(new column/new table) not support dynamic changed based on filter or slicer.
2. Measure can be affected by filter/slicer, so you can use it to get dynamic summary result in a visual by its row context.

https://www.sqlbi.com/articles/calculated-columns-and-measures-in-dax/

 

Second, since slicer is just a visual in report that use field from one table, so it couldn't affect the basic table or other tables any more, you could create a meausre and use it in visual level filetr to filter a table visual by slicer.

 

Regards,

Lin

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

Helpful resources

Announcements
November Update

Check it Out!

Click here to read more about the November 2020 Updates!

Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

secondImage

Power Platform October Community Highlights

Check out the top community contributors across all of the communities

secondImage

Create an end-to-end data and analytics solution

Learn how Power BI works with the latest Azure data and analytics innovations at the digital event with Microsoft CEO Satya Nadella.

Top Solution Authors
Top Kudoed Authors