Forum Discussion
Total not showing up
- 3 years ago
calerof OK, I believe this solves it:
m_Total Costo de Ventas Stock = VAR __table = SUMMARIZE ( ARTICULOS, ARTICULOS[ArtÃculo], "__value", [Costo de Venta de Stock] ) RETURN IF ( HASONEVALUE ( Costos[ARTICULO_ID] ), [Costo de Venta de Stock], SUMX ( __table, [__value] ) )
calerof OK, taking a closer look at this, is "Costa de Venta de Stock" really a measure? The reason I ask is that there are no aggregations around what appear to be columns unless those are also measures, like "Candidad Total". I'm having some trouble recreating this as the names of the columns, etc are different.
- calerof3 years ago
Impactful Individual
Hi Greg_Deckler ,
Yes, all columns are measures, not actual columns from the table. The Inventory table has the following columns:
- Item ID
- Warehouse ID
- Inputs in Units
- Outputs in Units
- Inputs in money
- Outputs in money
- Date
Inventory table
The measure Saldo Unidades (Inventory Balance Units) is:
Saldo Unidades = CALCULATE( SUM(Inventory[ENTRADAS_UNIDADES]) - SUM(Inventory[SALIDAS_UNIDADES]), 'Calendar'[Date] <= MAX('Calendar'[Date]) )The whole purpose is to know the COGS only of those items with beginning inventory. If they didn't have stock at the beginning of the month, then if it got purchased and then sold, it's not part of the KPI, only items sold that were in stock. Finally, the KPI will be an index of COGS with stock divided by total inventory.
The base measure, Costo de Ventas Stock (COGS from Stock) is just checking if the item sold this month had beginning inventory and then bringing in the COGS.
Many thanks!
F
- Greg_Deckler3 years ago
Community Champion
calerof OK, I'll need all of the measure formulas involved then. It's likely something buried in one of those formulas and quite likely involves CALCULATE perhaps.
- calerof3 years ago
Impactful Individual
Hi Greg_Deckler ,
Here are my measures:
Beginning Inventory (units) / Saldo Unidades Inicio de Mes; from the Inventory table, inputs minus outputs.
Saldo Unidades Inicio de Mes = VAR MaxDate = MAX('Calendar'[Date]) VAR EndOfMonthActual = ENDOFMONTH('Calendar'[Date]) VAR EndOfMonthPrevious = EOMONTH(EndOfMonthActual, - 1) VAR BeginningOfMonthBalance = CALCULATE( SUM(Inventory[ENTRADAS_UNIDADES]) - SUM(Inventory[SALIDAS_UNIDADES]), 'Calendar'[Date] <= EndOfMonthPrevious ) RETURN BeginningOfMonthBalanceEnding Inventory (units) / Saldo Unidades
Saldo Unidades = CALCULATE( SUM(Inventory[ENTRADAS_UNIDADES]) - SUM(Inventory[SALIDAS_UNIDADES]), 'Calendar'[Date] <= MAX('Calendar'[Date]) )Units Sold / Cantidad Total; from the Sales table, invoices minus credit memos (I know I should do this in Power Query).
Cantidad Total = CALCULATE( [Total Quantity], FILTER( Ventas, Ventas[TIPO_DOCTO] = "F" ) ) - CALCULATE( [Total Quantity], FILTER( Ventas, Ventas[TIPO_DOCTO] = "D" ) )COGS / Costo de Venta; from Material Master, unit cost times units sold.
Costo de Venta = SUMX( ARTICULOS, [Cantidad Total] * ARTICULOS[Unit Cost] )And finally COGS from stock and Total COGS from stock.
Thank you Greg!
F