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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
feralvarez994
Helper II
Helper II

Calculated table

Hi everyone, i have the following calculated table

TablaSemestres =
ADDCOLUMNS(
    GENERATESERIES(
        DATE(2000, 1, 1),
        DATE(2025, 12, 31),
        183
    ),
    "Fecha de compra",
        DATE(YEAR([Value]), IF(MONTH([Value]) <= 6, 1, 7), 1),
    "Fecha de venta",
        EOMONTH(DATE(YEAR([Value]), IF(MONTH([Value]) <= 6, 6, 12), 1), 0)
)
And the following calculated column
Stock =
-- CONTAR AUTOS COMPRADOS ANTES DE LA FECHA DE COMPRA Y VENDIDOS DESPUES DE LA FECHA DE VENTA (O QUE FECHA DE VENTA ESTÉ EN BLANCO),
-- ES DECIR, COMPRADOS VENDIDOS + COMPRADOS SIN VENDER,
-- QUE NO SEAN FLOTA NI OBSOLETA
var buydate = TablaSemestres[Fecha de compra]
var selldate = TablaSemestres[Fecha de venta]
var stock =
CALCULATE(
    COUNT(AUTOS[AT_COAUTO]),
    AUTOS[FECHA COMPRA] <= buydate
    &&AUTOS[Fecha Reserva] >= selldate || AUTOS[Fecha Reserva] = BLANK(),
    CLAAUTOS[CLAU_DETALLE] <> "FLOTA" && CLAAUTOS[CLAU_DETALLE] <> "OBSOLETA",
    ALL(TablaSemestres)
)
return IF(TablaSemestres[Value] > TODAY(), 0, stock)
feralvarez994_0-1679330567790.png

 

I want to add a new column in the calculated table with the different cities of the table (AUTOS) to get the stock of every city each semester. Can someone help me ?
1 REPLY 1
lbendlin
Super User
Super User

Instead of GENERATESERIES use a proper calendar table that includes a semester/half year column.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.