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

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.

Reply
Anonymous
Not applicable

Cuente los registros activos si hay entre dos fechas

Tengo 2 mesas, ver ejemplos aquí. En realidad, estas tablas son, por supuesto, mucho más grandes.

Fecha YearMonth
1-1-20102010-01
2-1-20102010-01
3-1-20102010-01
4-1-20102010-01
5-1-20102010-01
6-1-20102010-01

TherapyID StartDate Enddate Categoría
11-2-20102-4-2010Norte
214-2-201015-4-2010Sur
327-2-201028-4-2010Oeste
412-3-201011-5-2010Norte
525-3-201024-5-2010Norte
67-4-20106-6-2010Oeste

Quiero tener un gráfico con en el eje X el YearMonth y en el eje Y quiero el número de Terapia activa. Por lo tanto, IF StartDate <- último día de ese mes (YearMonth) Y SI EndDate > primer día de ese mes (YearMonth).

Por supuesto, quiero agregar una segmentación de datos para la categoría. ¿Debo reorganizar las tablas de ¿hay un cálculo inteligente que podría usar?

1 ACCEPTED SOLUTION

@gerwin024

No tienes que crear tres medidas, pero lo que has hecho está bien. El problema es que usted ha utilizado el [VAR_minDate] y [VAR_maxDate] al revés.

Lo corrigí como abajo, por favor inténtelo ahora

_count = COUNTROWS(FILTER(Table2,Table2[StartDate]>=[VAR_minDate]&&Table2[EndDate]<=[VAR_maxDate]))

________________________

Si mi respuesta fue útil, considere Aceptarla como la solución para ayudar a los otros miembros a encontrarla

Haga clic en el icono Thumbs-Up si le gusta esta respuesta 🙂

Youtube Linkedin

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

4 REPLIES 4
Fowmy
Super User
Super User

@gerwin024

Agregue esto como una medida a la tabla 1, en su gráfico, mantenga el campo Mes del año y use la medida. Cambie el nombre de Table1 y Table 2 y los nombres de columna según las tablas.

_Count = 
VAR __minDATE = MIN(Table1[Date])
VAR __maxDATE = MAX(Table1[Date])
RETURN
COUNTROWS(
    FILTER(
        'TABLE2',
        'TABLE2'[Start Date] >= __minDATE &&  'TABLE2'[End Date] <=  __maxDATE ) 
    )

________________________

Si mi respuesta fue útil, considere Aceptarla como la solución para ayudar a los otros miembros a encontrarla

Haga clic en el icono Thumbs-Up si le gusta esta respuesta 🙂

Youtube Linkedin

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Anonymous
Not applicable

Gracias, no era la fórmula que estaba buscando pero con tu ayuda conseguí la fórmula que quería!

Tal vez no lo describí correctamente, pero la siguiente fórmula me dio el resultado que quería:

_count - COUNTROWS(Table2)-COUNTROWS(TABLE2,Table2[StartDate]>-[VAR_maxDate]- Table2[EndDate]<-[VAR_minDate]))
Anonymous
Not applicable

@Fowmy 

I've got now 3 Measures:

_MinDate = MIN(Table1[Date])

_MaxDate = MAX(Table1[Date])

_count = COUNTROWS(FILTER(Table2,Table2[StartDate]>=[VAR_maxDate]&&Table2[EndDate]<=[VAR_minDate]))
 
With the table (see below) I want the following answers of how many Therapy's are active:
Feb-10: 3
Mar-10: 5
Apr-10: 6
May-10: 3
Jun-10: 1
 
The Measure doesn't give me this answers, am I doing something wrong?
 
TherapyID  StartDate    EndDate     Category
11-2-20102-4-2010North
214-2-201015-4-2010South
327-2-201028-4-2010West
412-3-201011-5-2010North
525-3-201024-5-2010North
67-4-20106-6-2010

West

@gerwin024

No tienes que crear tres medidas, pero lo que has hecho está bien. El problema es que usted ha utilizado el [VAR_minDate] y [VAR_maxDate] al revés.

Lo corrigí como abajo, por favor inténtelo ahora

_count = COUNTROWS(FILTER(Table2,Table2[StartDate]>=[VAR_minDate]&&Table2[EndDate]<=[VAR_maxDate]))

________________________

Si mi respuesta fue útil, considere Aceptarla como la solución para ayudar a los otros miembros a encontrarla

Haga clic en el icono Thumbs-Up si le gusta esta respuesta 🙂

Youtube Linkedin

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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