Forum Discussion
Anonymous
6 years agoNot applicable
Wrong Grand Totals Using SWITCH
Inscrição RAP = VAR InscricaoRAP = CALCULATE( SUMX( fEmpenho; fEmpenho[Saldo - R$ (Conta Contábil)]); FILTER(fEmpenho;fEmpenho[Conta Contábil] = "622920105" )) VAR InscricaoRAPLiquidar = CAL...
- 6 years ago
Hi Anonymous ,
We can try to use the following measure to meet your requirement, the 'Table'[Column] means the first column you used in the table visual:
Inscrição RAP = SUMX ( SUMMARIZE ( 'Table'; 'Table'[Column]; "Result"; VAR InscricaoRAP = CALCULATE ( SUM ( fEmpenho[Saldo - R$ (Conta Contábil)] ); fEmpenho[Conta Contábil] = "622920105" ) VAR InscricaoRAPLiquidar = CALCULATE ( SUM ( fEmpenho[Saldo - R$ (Conta Contábil)] ); fEmpenho[Conta Contábil] = "531110100" ) VAR ReinscricaoRAP = CALCULATE ( SUM ( fEmpenho[Saldo - R$ (Conta Contábil)] ); fEmpenho[Conta Contábil] = "531210000" ) VAR InscricaoConsolidada = SWITCH ( TRUE (); InscricaoRAP <> BLANK (); InscricaoRAP; InscricaoRAPLiquidar <> BLANK (); InscricaoRAPLiquidar; ReinscricaoRAP ) RETURN InscricaoConsolidada ); [Result] )
If it doesn't meet your requirement, kindly share your sample data and expected result to me if you don't have any Confidential Information. Please upload your files to One Drive and share the link here.
Best regards,
SteveCampbell
6 years agoMemorable Member
I'm unsure exactly how your code is working without more inofmration, but the grand total is not a sum of all the rows.
Instead, it is the DAX calculation with no row level context - the value in "rows" of your matrix.
I suiggest reading this article:
https://powerpivotpro.com/2012/03/subtotals-and-grand-totals-that-add-up-correctly/
Appreciate your Kudos
Connect with me!