Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Estimados tengo un problema espero me puedan ayudar:
Tengo una tabla calendario (dinamica), que usaré, pero necesito crear, una tabla auxiliar donde pueda elegir el Tipo de Agrupación y este me seleccione solo lasfechas que elegí, por ejemplo si elijo YTD_LY, me eliga las las fechas entre enero y hoy, pero del año anterior.
Adjunto el archivo pbix, con mi tabla calendario, esper me puedan ayudar
https://drive.google.com/file/d/1y66j1o2rNKqJYrtnoxxSFSbAK7WOAkwX/view?usp=sharing
Solved! Go to Solution.
@Syndicate_Admin , Pruebe como este ejemplo
Período de conmutación =
var _max = if(isfiltered('Date'),MAX( 'Date'[Date]) , today())
var _min =
SWITCH(SELECTEDVALUE(Period[PeriodType],"MTD"),
"YTD",eomonth(_max,-1*MONTH(_max))+1 , //FY Abril -Marzo
"LYTD",eomonth(_max,-1*MES(_max))+1 ,
"FYTD",if( Month(_max) <4 , date(year(_max)-1,4,1) ,date(year(_max),4,1)), //FY April -March
"QTD",eomonth(_max,-1* if( mod(Month(_max),3) =0,3,Month(_max)))+1,
"MTD",eomonth(_max,-1)+1 ,
"LMTD",eomonth(_max,-1)+1 ,
"LYMTD",eomonth(_max,-1)+1 ,
"WTD", _max -WEEKDAY(_max,2)+1,
"Cumm", Minx(ALLSELECTED('Date'),'Date'[Date]),
"Rolling 3", fecha(Año(_max), mes(_max) -3, Día(_max))+1,
"Rolling 6", fecha(Año(_max), mes(_max) -6, Día(_max))+1,
"Rolling 12", fecha(Año(_max), mes(_max) -12, Día(_max))+1,
EN BLANCO())
var _max1 = SWITCH(SELECTEDVALUE(Period[PeriodType],"MTD") ,
"LYTD",Fecha(Año(_max)-1, mes(_max), Día(_max))
"LMTD",Fecha(Año(_max), mes(_max)-1, Día(_max))
"LYMTD",Fecha(Año(_max)-1, mes(_max), Día(_max) ) ,
_max)
var _min1 = SWITCH(SELECTEDVALUE(Period[PeriodType],"MTD") ,
"LYTD",Fecha(Año(_min)-1, mes(_min), Día(_min))
"LMTD",Fecha(Año(_min), mes(_min)-1, Día(_min))
"LYMTD",Fecha(Año(_min)-1, mes(_min), Día(_min) ,
_min)
devolución
CALCULATE([net] ,DATESBETWEEN('Date'[Date],_min1,_max1))
Corrija los valores según la necesidad
Muchas gracias por si tiempo, espero que pueda adaptarla a la tabla calendario que ya tengo.
He actualizado su archivo pbix de muestra (ver archivo adjunto) para usted, por favor compruebe si eso es lo que desea.
1. Crear tabla de dimensiones de período
2. Cree una medida como la siguiente y aplique un filtro de nivel visual en la imagen con la condición (La medida es 1😞
Measure =
VAR _selperiod =
SELECTEDVALUE ( 'Periods'[Period] )
VAR _seldate =
SELECTEDVALUE ( 'Calendario'[Fecha] )
VAR _stdate =
TODAY ()
VAR _curyear =
YEAR ( _stdate )
VAR _lyeomonth =
EOMONTH ( DATE ( _curyear - 1, MONTH ( _stdate ), 1 ), 0 )
VAR _lycurdate =
IF (
DAY ( TODAY () ) > DAY ( _lyeomonth ),
_lyeomonth,
DATE ( _curyear - 1, MONTH ( _stdate ), DAY ( _stdate ) )
)
VAR _mat =
CALCULATETABLE (
VALUES ( 'Calendario'[Fecha] ),
FILTER (
'Calendario',
DATEDIFF ( _seldate, TODAY (), MONTH ) >= 0
&& DATEDIFF ( _seldate, _stdate, MONTH ) <= 12
)
)
VAR _lymat =
CALCULATETABLE (
VALUES ( 'Calendario'[Fecha] ),
FILTER (
'Calendario',
DATEDIFF ( _seldate, _lycurdate, MONTH ) >= 0
&& DATEDIFF ( _seldate, _lycurdate, MONTH ) <= 12
)
)
VAR _ytd =
DATESBETWEEN ( 'Calendario'[Fecha], DATE ( _curyear, 1, 1 ), _stdate )
VAR _lytd =
DATESBETWEEN ( 'Calendario'[Fecha], DATE ( _curyear - 1, 1, 1 ), _lycurdate )
VAR _q =
CALCULATETABLE (
VALUES ( 'Calendario'[Fecha] ),
FILTER (
'Calendario',
'Calendario'[Año] = _curyear
&& 'Calendario'[Quarter] = CONCATENATE ( "Q", QUARTER ( _stdate ) )
)
)
VAR _lyq =
CALCULATETABLE (
VALUES ( 'Calendario'[Fecha] ),
FILTER (
'Calendario',
'Calendario'[Año] = _curyear - 1
&& 'Calendario'[Quarter] = CONCATENATE ( "Q", QUARTER ( _stdate ) )
)
)
RETURN
SWITCH (
_selperiod,
"MAT", IF ( _seldate IN _mat, 1, 0 ),
"MAT_LY", IF ( _seldate IN _lymat, 1, 0 ),
"Q", IF ( _seldate IN _q, 1, 0 ),
"Q_LY", IF ( _seldate IN _lyq, 1, 0 ),
"YTD", IF ( _seldate IN _ytd, 1, 0 ),
"YTD_LY", IF ( _seldate IN _lytd, 1, 0 )
)
Si lo anterior no puede ayudarlo a obtener el resultado deseado, proporcione más detalles sobre su resultado esperado con lógica de backend y ejemplos especiales. Es mejor si puede compartir un archivo pbix simplificado con esta información. Puede consultar el siguiente enlace para cargar el archivo a la comunidad. Gracias.
Cómo subir PBI en la comunidad
Saludos
Muchas gracias, es exactamente lo que necesitaba.
Saludos
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
2 | |
2 | |
2 | |
2 | |
1 |