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

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
harshnathani
Community Champion
Community Champion

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
v-lili6-msft
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.
harshnathani
Community Champion
Community Champion

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)

 

 

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.