cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
Pillz
Frequent Visitor

Obtenga los últimos 6 meses en DAX con datos limitados

Mi conjunto de datos de ejemplo actual que estoy trabajando es el siguiente:

Nombre del eventoFechaTipo
Evento 113-Abr-20En persona
Evento 25-Mayo-20en línea
Evento 321-Jun-20en línea
Evento 45-Feb-20En persona
Evento 524-Feb-20en línea

Estoy tratando de usar DAX para crear una tabla que muestre el número de eventos en los últimos 6 meses, de forma similar a la siguiente. Sin embargo, sin datos en julio/agosto, no estoy seguro de cómo crear columnas para esos 2 meses. ¿Hay alguna forma de crear la tabla con estas restricciones?

Feb-20Mar-20Abr-2020 de mayoJunio-20Jul-2020 de agosto
En persona1010000
en línea1001100

2 REPLIES 2
Icey
Community Support
Community Support

Hola @Pillz ,

Si desea mostrar los últimos 6 meses en la tabla. Puede intentar crear una tabla de calendario. Hay dos maneras de lograr su funcionalidad: implementada con un filtro o implementada en una tabla.

1. implementado en un filtro:

a. Puede crear una tabla de calendario como la siguiente y luego ordenar la columna [MonthName-Year] por la columna [Mes-Año].

Calendar = 
ADDCOLUMNS (
    CALENDAR ( DATE ( 2019, 1, 1 ), DATE ( 2020, 12, 31 ) ),
    "Month", MONTH ( [Date] ),
    "Year", YEAR ( [Date] )
)
MonthName = FORMAT ( 'Calendar'[Date], "mmm" )
MonthName-Year = 'Calendar'[MonthName] & "-" & 'Calendar'[Year]
Month-Year = 'Calendar'[Month] & "-" & 'Calendar'[Year]

sort.jpg

b. Crear relaciones entre las dos tablas.

relation.jpg

c. Crear una medida.

count = COUNTROWS('Table')+0

d. Cree un objeto visual Matrix y establezca un filtro en el objeto visual.

matrix1.PNG

2. implementado en una tabla:

Puede crear una tabla de calendario dinámica que contenga solo las fechas de los 6 meses anteriores en función de la fecha de hoy.

Last 6 months = 
ADDCOLUMNS (
    CALENDAR ( EOMONTH ( TODAY (), -7 ) + 1, EOMONTH ( TODAY (), 0 ) ),
    "Month", MONTH ( [Date] ),
    "Year", YEAR ( [Date] )
)
MonthName = FORMAT('Last 6 months'[Date],"mmm")
MonthName-Year = 'Last 6 months'[MonthName]&"-"&'Last 6 months'[Year]
Month-Year = 'Last 6 months'[Month]&"-"&'Last 6 months'[Year]

Y luego, siga los pasos del método anterior. Sin embargo, no hay necesidad de filtrar en la fecha.

matrix2.PNG

Para obtener más detalles, consulte el archivo .pbix adjunto.

Saludos

Icey

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

parry2k
Super User
Super User

@Pillz deberías crear una medida como esta

Count = COUNTROWS ( Table ) + 0

y luego use esta medida en la matriz.

Me gustaría elogiossi mi solución ayudara.👉Si puedes pasar tiempo publicando la pregunta, también puedes hacer esfuerzos para dar a Kudos quien haya ayudado a resolver tu problema. ¡Es una muestra de agradecimiento!

Visítenos enhttps://perytus.com, su ventanilla única para proyectos/formación/consulta relacionadas con Power BI.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors