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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Soulus101
New Member

Dynamic ALL()

Hello, I'm new here so I hope I'm following conventions! Please shout if I can improve this query in any way.

 

I am trying to improve a set of inefficient measures, the first of which creates a formula which calculates a measure ignoring the context of either or both of a particular column. My current formula is this:

 

Underlying Total:= IF([Section]="All",
                      CALCULATE([Moving Total],ALL(Data[Age],Data[Product])),
                      IF([Section]="Age",
                         CALCULATE([Moving Total],ALL(Data[Age])),
                         CALCULATE([Moving Total],ALL(Data[Product]))))
                                       

 

 

[Section] evaluates the result of a slicer as either "All","Product" or "Age", [Moving Total] is a Moving Calculation. The next step would be to create a measure [Moving Total]/[Underlying Total], effectively giving me the proportion of the total for a given section of the book.

 

What I'd like to do is set up a VAR statement to define the variables used in ALL(), but the following fails due to the fact that IF() cannot return a table:

 

 

Underlying Total:=
                  VAR Sel = IF([Section]="All", 
ALL(Data[Age],Data[Product]), IF([Section]="Age", ALL(Data[Age]), ALL(Data[Product)))
RETURN
CALCULATE([Moving Total] , Sel)

 

Does anyone have a way of Defining "Sel" such that it returns the desired context? If this means changing the way I use the [Section] variable I'm all ears. I'm afraid my table manipulation skill is simply not up to this challenge.

1 REPLY 1
v-chuncz-msft
Community Support
Community Support

@Soulus101,

 

As far as I know, this is not supported. You may submit an idea via https://ideas.powerbi.com/forums/265200-power-bi.

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

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

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.

Top Solution Authors