Get certified for free when you join Fabric Data Days 2026 and dive into Fabric, Power BI, SQL, AI, and other essential data skills.
Join nowJuly 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more
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.
As far as I know, this is not supported. You may submit an idea via https://ideas.powerbi.com/forums/265200-power-bi.
Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.
Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.
| User | Count |
|---|---|
| 28 | |
| 27 | |
| 25 | |
| 22 | |
| 18 |
| User | Count |
|---|---|
| 52 | |
| 49 | |
| 43 | |
| 36 | |
| 36 |