Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

Reply
julien-rivley
Helper I
Helper I

Using all to return a table

Hello,

I have a Fact table like this:

ProductCustomerRegionDateSales


In the middle of a calculation, I would like to put that table in a variable with the following filter:

Based on contextBased on contextBased on contextAny dateBased on context
ProductCustomerRegionDateSales


ALL seems to be the right function but I only manage to use it in a calculation with formula like this:

CALCULATE(
SUM(Fact[Sales] ,
All(Fact[Date]))

How could I use it to return the table above?

Thanks for your help!

1 ACCEPTED SOLUTION
d_gosbell
Super User
Super User

I'm a bit worried about why you might want to do this as it could lead to performance issues and there might be alternative faster approaches. But to answer your question you could use the CALCULATETABLE function to create a table variable with an altered filter context.

eg.

 

VAR _factAllDates = CALCULATETABLE( Fact, ALL( Fact[Date] ) )

View solution in original post

3 REPLIES 3
d_gosbell
Super User
Super User

I'm a bit worried about why you might want to do this as it could lead to performance issues and there might be alternative faster approaches. But to answer your question you could use the CALCULATETABLE function to create a table variable with an altered filter context.

eg.

 

VAR _factAllDates = CALCULATETABLE( Fact, ALL( Fact[Date] ) )

Thanks a lot!

 

Yes, I have some tricky calculation to do and I could not find anyother solution than this... Ultimately, the goal is to design something similar to this:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Days-of-Supply/m-p/635656

Julien


@julien-rivley wrote:

Thanks a lot!

 

Yes, I have some tricky calculation to do and I could not find anyother solution than this... Ultimately, the goal is to design something similar to this:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Days-of-Supply/m-p/635656

Julien


That's fine and the CALCULATETABLE approach should work, but you might find your performance is better doing some sort of ALL() over your date dimension rather than a CALCULATETABLE over your fact.

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.