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

Prepping for a Fabric certification exam? Join us for a live prep session with exam experts to learn how to pass the exam. Register now.

Reply
Anonymous
Not applicable

Año fiscal - Ventas de YTD para años anteriores

Hola a todos, @Greg_Deckler @amitchandak

El año fiscal de mi conjunto de datos comienza entre 01/Sep - 31/Aug .

La hoja de datos de muestra tiene datos de ventas hasta el 25/Mar/2020.

Quiero añadir mis ventas desde 01/sep/19 hasta el 25/Mar/20 ; 01/sep/18 hasta el 25/Mar/19 y así sucesivamente para años anteriores.

Descargar datos de ventas de ejemplo:

https://we.tl/t-tmMSnmlZGb

Salida esperada basada en el conjunto de datos compartido:

YTD_Output.png

He probado la solución del siguiente post, pero no funcionó en este caso

https://community.powerbi.com/t5/Desktop/Last-Year-and-Year-before-with-30-June-Fiscal-Year/m-p/9132...

https://community.powerbi.com/t5/Desktop/Previous-Fiscal-YTD-DAX-Not-working/m-p/906945#M434676

Todas las fechas son el formato de fecha y hora en SQL Database

La selección de idiomas de powerbi y sistema es Inglés (nosotros)

La tabla [Fecha] se marca como Tabla de fechas

La relación se crea entre la tabla Sales y la tabla de fechas 1-0-1

La tabla de fechas se crea de la siguiente manera:

Fecha de la fecha ?
VAR MinYear - AÑO(MIN(Sales_Data[Sales_Date]))
VAR MaxYear - Año(MAX(Sales_Data[Sales_Date]))
devolución
ADDCOLUMNS (
FILTRO (
CALENDARAUTO( ),
Y ( Año ( [Fecha] ) > - Año Mínimo, AÑO ( [Fecha] ) <-MaxYear )
),
"Año de la tercera edad", IF(MONTH([Fecha]) > 9 , (Año([Fecha]) + 1), AÑO([Fecha])),
"Año calendario", "CY" & YEAR ( [Fecha] ),
"Month Name", FORMAT ( [Fecha], "mmmm" ),
"Número de mes", MES ( [Fecha] ),
"Weekday", FORMAT ( [Fecha], "dddd" ),
"Número de día de la semana", WEEKDAY( [Fecha] ),
"Cuarto", "Q" & TRUNC ( ( MES ( [Fecha] ) - 1 ) / 3 ) + 1
)
Por favor guía, ¿dónde va mal
Muchas gracias

4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hola

Puede descargar mi archivo PBI desde aquí.

Espero que esto ayude.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-alq-msft
Community Support
Community Support

Hola, @mridul

Según mi investigación, puede crear una tabla calculada con la siguiente fórmula.

Calendar = CALENDARAUTO()

Hay una relación uno a uno entre dos tablas. A continuación, puede crear una medida como se muestra a continuación.

Result = 
var _year = SELECTEDVALUE('Calendar'[Date].[Year])
return

CALCULATE(
    SUM(Sales_Data[Sales]),
    FILTER(
        ALL('Calendar'),
        'Calendar'[Date]>=DATE(_year-1,9,1)&&
        'Calendar'[Date]<=DATE(_year,3,25)
    )
)

Resultado:

d1.png

Saludos

Allan

Si este post ayuda,entonces por favor considere Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.

Anonymous
Not applicable

@v-alq-msft

Hola Allan,

Modifiqué un poco para obtener la misma fecha el año pasado y también incluí la condición del año bisiesto. Funciona bien como se esperaba.
Pero, me preguntaba, si hay alguna función para obtener la misma salida

Resultado ?
var _FYyear á SELECTEDVALUE('Fecha'[Año FY])

devolución

CALCULAR(
SUM(Sales_Data[Ventas]),
FILTRO (
ALL('Fecha'),
'Fecha'[Fecha] >' FECHA(_FYyear - 1 , 9, 1) &&
'Fecha'[Fecha] <- IF(TODAY() <-FECHA(_FYyear - 1, 12, 31),
FECHA ( _FYyear - 1 ,MES (HOY()), DIA (HOY())),
IF(MOD(_FYyear,4) á 0 && MES(HOY()) á 2 && DIA(HOY()) a 29, BLANK(),
FECHA( _FYyear ,MES (HOY()), DIA (HOY()))))
) )

Anonymous
Not applicable

@allan Gracias por su respuesta

En la base de datos real, no será 1-0-1, se trataba de un ejemplo de datos y 25 fecha será una variable, porque el informe se actualiza automáticamente todos los días. Por lo tanto, durante todo el año anterior la fecha será incremental.

Por favor, sugiera.

Helpful resources

Announcements
PBIApril_Carousel

Power BI Monthly Update - April 2025

Check out the April 2025 Power BI update to learn about new features.

Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

April2025 Carousel

Fabric Community Update - April 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors
Top Kudoed Authors