cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
julien-rivley Frequent Visitor
Frequent Visitor

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

Accepted Solutions
Highlighted
Super User III
Super User III

Re: Using all to return a table

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
Highlighted
Super User III
Super User III

Re: Using all to return a table

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

julien-rivley Frequent Visitor
Frequent Visitor

Re: Using all to return a table

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

Super User III
Super User III

Re: Using all to return a table


@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
Exclusive LIVE Community Event #3 – Ask Arun Anything

Exclusive LIVE Community Event #3 – Ask Arun Anything

Join us in the third Triple A event!

Meet the 2020 Season 1 Power BI Super Users!

Meet the 2020 Season 1 Power BI Super Users!

It’s the start of a new Super User season! Learn all about the new Super Users and brand-new tiered recognition system.

Super User Challenge: Can You Solve These?

Super User Challenge: Can You Solve These?

We're celebrating the start of the New Super User season with our first ever Super User 'Can You Solve These?' challenge.

Power BI Desktop Update - February 2020

Power BI Desktop Update - February 2020

We are super excited for our update this month, as we are releasing two of our top community requests!

Power Platform Online Conference

Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

Top Solution Authors