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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Syndicate_Admin
Administrator
Administrator

Segmentación dinámica de YTD, QTD, MTD según la segmentación de datos de intervalo de tiempo

Hola, tengo el siguiente problema. Tengo una segmentación de datos que filtra en un período de tiempo (por ejemplo, 01/01/2021 - 31/12/2021). Ahora quiero crear una segmentación de datos adicional que filtre en YTD, QTD o en valores MTD dependiendo de la fecha de finalización. Para ello he creado la siguiente Tabla Calculada y la he vinculado a mi calendario en el modelo:

Selección MTD/QTD/YTD =

VAR lastselecteddate =CALCULATE(

MAX(Datos[Fecha],

ALLSELECTED(Datos[Fecha]

)

VAR YearStart = CALCULAR(

INICIODEAÑO(datos[fecha],

AÑO(Datos[Fecha]=AÑO(última fechaseleccionada)

)

VAR Quarterstart = CALCULAR(

STARTOFQUARTER(Datos[Fecha],

AÑO(Datos[Fecha]=AÑO(última fecha),

TRIMESTRE(Datos[Fecha]=TRIMESTRE(última fechaseleccionada))

VAR MonthStart = CALCULATE(

STARTOFMONTH(Datos[Fecha],

MES(Datos[Fecha]=MES(última fechaseleccionada),

AÑO(Datos[Fecha]=AÑO(última fecha))

Resultado VAR =

SINDICATO(

ADDCOLUMNS(

CALENDAR(YearStart,lastselecteddate),

"Selección", "YTD"

),

ADDCOLUMNS(

CALENDAR(Quarterstart,lastselecteddate),

"Selección", "QTD"

),

ADDCOLUMNS(

CALENDAR(MonthStart,lastselecteddate),

"Selección", "MTD"

)

)

DEVOLUCIÓN

Resultado

Mi problema es: la nueva segmentación de datos YTD, QTD, MTD solo funciona si la fecha de finalización de mi segmentación de datos de período es en 2023 (últimas fechas disponibles de todo el conjunto de datos). Si elijo un período de tiempo anterior (por ejemplo, el año 2022) ya no funciona. ¿Puede alguien ayudarme a resolver este problema?

1 REPLY 1
Syndicate_Admin
Administrator
Administrator

@Gordian_S,

¿Ha intentado utilizar un grupo de cálculo? Es una forma conveniente de crear YTD / QTD / MTD.

https://www.sqlbi.com/articles/introducing-calculation-groups/

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

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

Top Kudoed Authors