Forum Discussion
Count column using filter
- Anonymous3 years ago
Hi Anonymous ,
According to your statement, I think Dim_Chamadas table should have directly relationship with Fact_Tipificacao. This issue should be caused by relationship, like many to many. Here I suggest you to add some filter in "teste" part.
Code should look like as below. You need to replace the Dim_Chamadas[ColumnName] and Fact_Tipificacao[ColumnName] by related column name in both tables.
table = ADDCOLUMNS ( SUMMARIZE ( Fact_Tipificacao, [Produto], Dim_Data[BK_Data], Dim_Vendedor[BK_Vendedor] ), "Total Quantity", CALCULATE ( SUM ( Fact_Tipification[Quantity] ) ), "teste", COUNTROWS ( FILTER ( Dim_Chamadas, Dim_Chamadas[ColumnName] = EARLIER ( Fact_Tipificacao[ColumnName] ) && Dim_Chamadas[1Nivel] = "Sale" ) ) )
Best Regards,
Rico ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Anonymous ,
According to your statement, I think Dim_Chamadas table should have directly relationship with Fact_Tipificacao. This issue should be caused by relationship, like many to many. Here I suggest you to add some filter in "teste" part.
Code should look like as below. You need to replace the Dim_Chamadas[ColumnName] and Fact_Tipificacao[ColumnName] by related column name in both tables.
table =
ADDCOLUMNS (
SUMMARIZE (
Fact_Tipificacao,
[Produto],
Dim_Data[BK_Data],
Dim_Vendedor[BK_Vendedor]
),
"Total Quantity", CALCULATE ( SUM ( Fact_Tipification[Quantity] ) ),
"teste",
COUNTROWS (
FILTER (
Dim_Chamadas,
Dim_Chamadas[ColumnName] = EARLIER ( Fact_Tipificacao[ColumnName] )
&& Dim_Chamadas[1Nivel] = "Sale"
)
)
)
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.