Forum Discussion
Total value missing in calculated column
Hi,
I am having an issue in getting the total value displayed in the red circle I have marked in this snapshot.
A little bit of context: that last column is caclulated column. We are not allowed to use measures in this report.
The calculated column is derived from this formula:
Vol_L12M = CALCULATE(
sum(FactMain[GBPVolume]),
FILTER(
FactMain, FactMain[ColumnType]="Revenue" &&
FactMain[ClientID]=Clients_Snowflake[ClientID] &&
FactMain[TradeDate]>= EDATE(today(), -12)
)
)
When I set the summarization to "SUM" I get incorrect and repeating values.
Does anyone know how to fix and get around this problem?
Thank You,
M
Calculated columns cannot respond to slicers. Full stop. No workaround, no clever DAX trick will change that. The moment you need a dynamic total that reacts to a filter/slicer, you need a measure. That's not optional, it's just how Power BI's engine works.
Your options are:
Push back on the "no measures" rule:show whoever made that decision this exact problem. The rule is likely a misunderstanding or an old policy that didn't anticipate this use case.
Fix it at the data source:pre-aggregate the 12-month GBP volume per client in your SQL/dataflow before it even hits Power BI. Then it's just a plain column with no aggregation ambiguity, and slicers will work naturally.
Live with the wrong total: hide the total row for that column specifically using visual formatting, so users never see the misleading number.
There is no Option 4 that involves a calculated column and a correct slicer-aware total. Anyone who tells you otherwise is wrong.Hope this helps! Don't forget to accept as solution ✅ and thumbs up 👍 in order to keep helping others.
Best regards,
Oussama (Data Consultant - Expert Fabric & Power BI)
7 Replies
- MFelixSuper User
Hi mp390988 ,
This is a question of context. Just to clarify a litle bit the question when you refer that you are not allowed to use measures on this report and you need to use calculated columns what is the meaning of this?
I would assume that this would be the other way around because calculated columns are increasing the model size and the complexity while measures are calculated at the time you call them so not adding to the size of the reports and data.On top of that you have the question about the context calculated columns are at row level, this means that when you alter the context in this case using filter you will get a bigger number that actual you need in this case I believe that what you need if you are using a calculated column is the following code:
Vol_L12M = IF( FactMain[ColumnType]="Revenue" && FactMain[TradeDate]>= EDATE(today(), -12) , FactMain[GBPVolume])I have remove the value for the Client because I assume it's a dimension table and will get the correct value based on the column you place on the visual.
Has I refer I believe that you should use a measure, if you are making a report based on a publish semantic model if you add a measure thar measure will be specific to that report so would not impact the semantic model that way you would free yourself from that rule of the column vs measure.
Check this blog posts below about Columns vs measures:
https://www.sqlbi.com/articles/calculated-columns-and-measures-in-dax/
https://www.sqlbi.com/tv/measures-vs-calculated-columns-in-dax-and-power-bi/
https://data-mozart.com/calculated-columns-vs-measures-in-power-bi/
- oussamahaimoudMemorable Member
Hi mp390988,
Hope you're doing well!
Since you can't use measures, you need to prevent double-counting at the total row. The trick is to create a second calculated column on the same table that returns the value only once per unique client, and zeros out duplicates. But actually the cleaner and fully supported workaround is this:
Create a helper calculated column on Clients_Snowflake:
Vol_L12M =
CALCULATE(
SUM(FactMain[GBPVolume]),
FILTER(
ALL(FactMain),
FactMain[ColumnType] = "Revenue" &&
FactMain[ClientID] = EARLIER(Clients_Snowflake[ClientID]) &&
FactMain[TradeDate] >= EDATE(TODAY(), -12)
)
)
This alone won't fix the total. So for the total row to be correct, you need to change the column summarization to "Minimum" (or Maximum) instead of Sum. But for the grand total, Minimum across all clients would still be wrong. So the real complete solution is:
Column 1 (already have this, Vol_L12M, keep as is)
Column 2 on Clients_Snowflake, deduplicated flag:
Vol_L12M_Deduped =
VAR CurrentClient = Clients_Snowflake[ClientID]
VAR RowRank =
RANKX(
FILTER(Clients_Snowflake, Clients_Snowflake[ClientID] = CurrentClient),
Clients_Snowflake[Vol_L12M],
,
ASC,
Dense
)
RETURN
IF(RowRank = 1, Clients_Snowflake[Vol_L12M], 0)
Then use Vol_L12M_Deduped in the visual with SUM, each client's value only contributes once to the total.
Hope this helps! Don't forget to accept/mark as solution and thumbs up 👍 in order to keep helping others.
Best regards,
Oussama (Data Consultant - Expert Fabric & Power BI)
- mp390988Post Partisan
Hi oussamahaimoud ,
Thank you for your reply. Appreciate your time and effort 🙂Your suggested solution has almost worked but it requires the original Vol_L12M column to still be left in the visual as shown below:
If I remove this field from the visual, which is what I ideally want to do, then the new field you suggested Vol_L12_Deduped shows wrong values (theoretcially not wrong values but values that I don't expect to see, if you know what I mean).
I have found a way to hide the original Vol_L12 (using visual formatting techniques) but what I have noticed the total value for Vol_L12_Deduped remains the same regardless of the value I select in the slicer "Dealer Team". So for example, if I choose "Risk Management" as the value for the Dealer Team slicer, the total value = 9,513,609,075.71. But when I change the value of the slicer to say "Derivatives", the total value is still showing 9,513,609,075.71 which is wrong.Thank You,
M
- oussamahaimoudMemorable Member
Calculated columns cannot respond to slicers. Full stop. No workaround, no clever DAX trick will change that. The moment you need a dynamic total that reacts to a filter/slicer, you need a measure. That's not optional, it's just how Power BI's engine works.
Your options are:
Push back on the "no measures" rule:show whoever made that decision this exact problem. The rule is likely a misunderstanding or an old policy that didn't anticipate this use case.
Fix it at the data source:pre-aggregate the 12-month GBP volume per client in your SQL/dataflow before it even hits Power BI. Then it's just a plain column with no aggregation ambiguity, and slicers will work naturally.
Live with the wrong total: hide the total row for that column specifically using visual formatting, so users never see the misleading number.
There is no Option 4 that involves a calculated column and a correct slicer-aware total. Anyone who tells you otherwise is wrong.Hope this helps! Don't forget to accept as solution ✅ and thumbs up 👍 in order to keep helping others.
Best regards,
Oussama (Data Consultant - Expert Fabric & Power BI)
- mp390988Post Partisan
oussamahaimoud - thank you for your suggestions. Much appreciated as always!
- MFelixSuper User
Hi mp390988 ,
Have you tried the calculation that I have provided in the previous post I did.
Believe that if you tweak the code you have you will have a calculation that will responde to your slicers based on the value of the column.
The main problem I identify with your column is that when you do the SUM and add the filter of the customer you get on that specific column a duplicated value that will then get incorrect totals.