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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
SandraCalc
Frequent Visitor

Error in measure for matrix or table

Hello,

I have an issue with a measure named TotalValoresDRE. When used in conjunction with the Values column in the "Invoicing by employee" row, it doesn't display any data, although it should display the value 75952. Let me explain the data:

  1. I have a table named dFormatoDRE, which is imported from Excel and consists of the following columns: Order, Rubric, Total.

  2. I also have another table named fMovimentos, which includes the following columns: Account, Value.

  3. Additionally, there's a table named dPlanoContas that has columns for Account and CodDRE.

I need to create a table that includes the following information: Rubric and Values. The Rubric column is derived from the Rubric column in the dFormatoDRE table, and the Values column is generated using a measure. This measure includes variables that sum the values in the Value column from the fMovimentos table, filtered by accounts. There is an active relationship between the dFormatoDRE table and the dPlanoContas table, linking dFormatoDRE.Order to dPlanoContas.CodDRE. There is also an active relationship between the dPlanoContas table and the fMovimento table, linked via dPlanoContas.Account and fMovimentos.Account.

The measure, designed to populate the rows of the matrix, should retrieve values from its rows based on the combination of Totaliza and Order, and it is as follows: [Here you can include the DAX formula you mentioned]

 

 

Tests I have already performed:

  1. All measures used individually in cards work correctly.
  2. If, instead of a measure or a variable, I use a string, the row displays that word.

RETURN
SWITCH(
TRUE(),
vTotaliza = 0, vTotalCBL,
vTotaliza = 1 && vOrdem = 3, vNColaboradores,
vTotaliza = 1 && (vOrdem = 7 || vOrdem = 10), vSubtotalCBL,
vTotaliza = 2, "test"
)
If I create this measure:

Test Table =
"Text for testing"

And then in the measure:

RETURN
SWITCH(
TRUE(),
vTotaliza = 0, vTotalCBL,
vTotaliza = 1 && vOrdem = 3, vNColaboradores,
vTotaliza = 1 && (vOrdem = 7 || vOrdem = 10), vSubtotalCBL,
vTotaliza = 2, [Test Table]
)

It correctly returns the phrase.

  1. I've already tried to convert the value of vRentColaborador using both FORMAT and CONVERT, but it didn't work.

Does anyone know how to resolve this issue?





-- na minha linguagem nativa;

Viva,
Tenho um probleme com uma medida TotalValoresDRE, que na conjugação da coluna Valores na linha Facturação por colaborador, não mostra nada, e deveria mostrar o valor 75952. Explico agora os dados:
1 Tenho uma tabela dFormatoDRE que é importada do excel e que tem as seguintes colunas: Ordem, Rubrica, Totaliza.
2 Tenho também uma tabela fMovimentos que tem as seguintes colunas: Conta, Valor
3 E a tabela dPlanoContas que tem as colunas Conta e CodDRE

Preciso de criar uma tabela que tenha as seguintes informações: Rubrica e Valores. A coluna Rubrica é a coluna Rubrica da tabela dFormatoDRE, e a coluna Valores é duma medida. Essa medida tem como variáveis outras medidas que somam os valores da coluna Valor da tabela fMovimentos, filtrada pelas contas. Há um relacionamento activo entre a tabela dFormatoDRE e a tabela dPlanoContas de dFormatoDRE.Odem para dPlanoContas.CodDRE. Há também um relacionamento activo entre a tabela dPlanoContas e a tabela fMovimento em dPlanoContas.Conta e fMovimentos.Conta.

A medida para preencher as linhas da matriz, deve ir buscar os valores das suas linhas consoante a conjugação de Totaliza e Ordem, e é esta:

 

 

 

Total Valores DRE = 
VAR vTotaliza = SELECTEDVALUE(dFormatoDRE[Totaliza]) 
VAR vOrdem = SELECTEDVALUE(dFormatoDRE[Ordem]) 
VAR vTotalCBL = -SUM(fMovimentos[Valor]) 
VAR vSubtotalCBL = CALCULATE( [Total Movimentos CBL], FILTER( ALL(dFormatoDRE), dFormatoDRE[Ordem] <= MAX(dFormatoDRE[Ordem]) ) ) 
VAR vNatureza = SELECTEDVALUE(fMovimentos[Natureza]) 
VAR vNColaboradores = FORMAT( CALCULATE( COUNTROWS(dFuncionarios) - CALCULATE( COUNTROWS(dFuncionarios), dFuncionarios[Data Final] <> BLANK(), USERELATIONSHIP( dCalendario[Data], dFuncionarios[Data Final] )), FILTER( ALL( dCalendario), dCalendario[Data] <= MAX(dCalendario[Data] ) ) ) , 0) 
VAR vRentColaborador = DIVIDE((CALCULATE( SUMX(fMovimentos, fMovimentos[Valor]), FILTER( dPlanoContas, dPlanoContas[Conta Razão] = "71" || dPlanoContas[Conta Razão] = "72" ) )), vNColaboradores, 0) 
RETURN
 SWITCH( TRUE(), 
 vTotaliza = 0, vTotalCBL, 
 vTotaliza = 1 && vOrdem = 3, vNColaboradores,
 vTotaliza = 1 && (vOrdem = 7 || vOrdem = 10), vSubtotalCBL, 
 vTotaliza = 2, vRentColaborador )

 

 

 



Copia também a tabela excel dFormatoDRE, à qual acrescentei 2 colunas apenas para informação: a coluna Valores e Fórmulas apenas para perceber melhor os cálculos:

OrdemRubricaTotalizaValoresFórmulas
1Facturação0227856,52[Volume de Negácios]
2Gastos com o pessoal045055,3[Gastos com pessoal]
3Nº de colaboradores13[Funcionários Activos]
4Facturação por colaborador275952,17333=E2/E4
5Gastos gerais015000[Gastos Gerais]
6Depreciações01000[Depreciações]
7Resultado operacional1166801,22=E2-E3-E6-E7
8Outros rendimentos025[Outros Rendimentos]
9Outros gastos0785[Outros Gastos]
10Resultado estimado1166041,22=E8+E9-E10
11Erros0  




Testes que já fiz: 

1 Total as medidas usadas individualmente em cartão funcionam.
2 Se em vez de medida ou variá vel, usar uma string, e linha mostra essa palavra

RETURN

SWITCH(
    TRUE(),
    vTotaliza = 0, vTotalCBL,
    vTotaliza = 1 && vOrdem = 3, vNColaboradores,
    vTotaliza = 1 && (vOrdem = 7 || vOrdem = 10), vSubtotalCBL,
    vTotaliza = 2, "teste"
    )
 

3 Se fizer esta medida:

Teste tabela =
"texto para teste"

e na medida 

RETURN

SWITCH(
    TRUE(),
    vTotaliza = 0, vTotalCBL,
    vTotaliza = 1 && vOrdem = 3, vNColaboradores,
    vTotaliza = 1 && (vOrdem = 7 || vOrdem = 10), vSubtotalCBL,
    vTotaliza = 2, [Teste tabela]
    )
retorna bem a frase

4 Já tentei converter o valor de vRentColaboborador usando o format e o convert, não resulta.

 
 
Alguém saberá resolver?



0 REPLIES 0

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.