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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! 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
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

Check out the July 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.