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
dannytango
Regular Visitor

Cómo calcular una fórmula de producto rodante basada en la segmentación de fecha

Hola

Estoy tratando de calcular para hacer el cálculo del producto en cada fila, pero solo puedo obtener que se calcule desde el principio del conjunto de datos en lugar de calcular en función de la fecha de segmentación de datos. Como se puede ver en la primera imagen y la segunda imagen. En la segunda imagen después de aplicar la segmentación de datos, debe empezar a calcular desde el principio de nuevo y el resultado acumulado debe ser 94,8%.

Gracias por su ayuda.

dannytango_1-1603505973995.png

dannytango_0-1603504749889.png

1 ACCEPTED SOLUTION
v-eqin-msft
Community Support
Community Support

Hola @dannytango ,

Según mi opinión, desea calcular elccumula de medida dinámicamente basado en Slicer, ¿verdad?

Puede seguir estos pasos:

1. Cree una nueva tabla con Fecha para la segmentación.

2. Utilice la siguiente fórmula:

test =
VAR _min =
    MIN ( 'forSlicer'[Date] )
VAR _max =
    MAX ( 'forSlicer'[Date] )
RETURN
    CALCULATE (
        PRODUCTX ( TCMMonthlyReturnsInput, TCMMonthlyReturnsInput[MRTCM] + 1 ),
        FILTER (
            TCMMonthlyReturnsInput,
            'TCMMonthlyReturnsInput'[Date] >= _min
                && 'TCMMonthlyReturnsInput'[Date] <= MAX ( 'TCMMonthlyReturnsInput'[Date] )
        )
    ) - 1

3. Aplique la medida a continuación al panel de filtro (conjunto n.o 1)

Measure =
VAR _min =
    MIN ( 'forSlicer'[Date] )
VAR _max =
    MAX ( 'forSlicer'[Date] )
RETURN
    IF (
        MAX ( 'TCMMonthlyReturnsInput'[Date] ) >= _min
            && MAX ( 'TCMMonthlyReturnsInput'[Date] ) <= _max,
        1,
        0
    )

4. Calcule el valor acumulado:

Final Accumulate test =
CALCULATE (
    SUMX ( 'TCMMonthlyReturnsInput', [test] ),
    FILTER (
        ALL ( 'TCMMonthlyReturnsInput' ),
        'TCMMonthlyReturnsInput'[Date] <= MAX ( 'TCMMonthlyReturnsInput'[Date] )
            && [Measure] = 1
    )
)

Mi visualización tiene este aspecto:

10.27.5.1.gif

Aquí está el archivo pbix.

¿He respondido a tu pregunta? Por favor, marque mi respuesta como solución. Muchas gracias.
Si no es así, cargue algunas muestras de datos insensibles y la salida esperada.

Saludos
Eyelyn Qin

View solution in original post

5 REPLIES 5
v-eqin-msft
Community Support
Community Support

Hola @dannytango ,

Según mi opinión, desea calcular elccumula de medida dinámicamente basado en Slicer, ¿verdad?

Puede seguir estos pasos:

1. Cree una nueva tabla con Fecha para la segmentación.

2. Utilice la siguiente fórmula:

test =
VAR _min =
    MIN ( 'forSlicer'[Date] )
VAR _max =
    MAX ( 'forSlicer'[Date] )
RETURN
    CALCULATE (
        PRODUCTX ( TCMMonthlyReturnsInput, TCMMonthlyReturnsInput[MRTCM] + 1 ),
        FILTER (
            TCMMonthlyReturnsInput,
            'TCMMonthlyReturnsInput'[Date] >= _min
                && 'TCMMonthlyReturnsInput'[Date] <= MAX ( 'TCMMonthlyReturnsInput'[Date] )
        )
    ) - 1

3. Aplique la medida a continuación al panel de filtro (conjunto n.o 1)

Measure =
VAR _min =
    MIN ( 'forSlicer'[Date] )
VAR _max =
    MAX ( 'forSlicer'[Date] )
RETURN
    IF (
        MAX ( 'TCMMonthlyReturnsInput'[Date] ) >= _min
            && MAX ( 'TCMMonthlyReturnsInput'[Date] ) <= _max,
        1,
        0
    )

4. Calcule el valor acumulado:

Final Accumulate test =
CALCULATE (
    SUMX ( 'TCMMonthlyReturnsInput', [test] ),
    FILTER (
        ALL ( 'TCMMonthlyReturnsInput' ),
        'TCMMonthlyReturnsInput'[Date] <= MAX ( 'TCMMonthlyReturnsInput'[Date] )
            && [Measure] = 1
    )
)

Mi visualización tiene este aspecto:

10.27.5.1.gif

Aquí está el archivo pbix.

¿He respondido a tu pregunta? Por favor, marque mi respuesta como solución. Muchas gracias.
Si no es así, cargue algunas muestras de datos insensibles y la salida esperada.

Saludos
Eyelyn Qin

dannytango
Regular Visitor

El código devolvió el total del cálculo correctamente, pero no calcula para cada fila. No se pudo cargar el archivo pbix, así que tengo que poner pegarlo en la tabla de abajo. Gracias.

FechaMRTCM
1/31/20170.66%
2/28/20170.21%
3/31/20170.96%
4/30/20170.66%
5/31/20175.21%
6/30/20174.20%
7/31/20179.14%
8/31/20178.62%
9/30/20173.12%
10/31/201714.91%
11/30/20173.09%
12/31/2017-0.26%
1/31/201811.04%
2/28/20184.16%
3/31/2018-7.44%
4/30/2018-2.48%
5/31/201824.14%
6/30/20180.99%
7/31/2018-0.97%
8/31/20188.98%
9/30/20180.84%
10/31/2018-16.97%
11/30/2018-7.69%
12/31/2018-31.07%
1/31/201923.02%
2/28/20190.24%
3/31/20198.83%
4/30/201910.56%
5/31/2019-23.15%
6/30/201929.09%
7/31/201910.17%
8/31/2019-7.13%
9/30/20192.98%
10/31/20198.71%
11/30/20193.65%
12/31/20193.76%
1/31/20207.39%
2/29/20200.98%
3/31/2020-3.48%
4/30/202024.12%
5/31/20208.34%
6/30/20207.90%
7/31/20206.49%
8/31/20203.00%
9/30/20200.01%
dannytango
Regular Visitor

Gracias, @AllisonKennedy

Lo siento, pero soy bastante nuevo en DAX, así que no creo que haya aplicado tu consejo correctamente. Este es mi intento siguiendo su consejo:

TCMPrueba acumulada ?
var startDate á MIN(TCMMonthlyReturnsInput[Date]) return
CALCULATE(PRODUCTX(TCMMonthlyReturnsInput,TCMMonthlyReturnsInput[MRTCM]+1),
ALLSELECTED(TCMMonthlyReturnsInput[Date],TCMMonthlyReturnsInput[MRTCM]),
FILTER(TCMMonthlyReturnsInput,startdate<-MAX(TCMMonthlyReturnsInput[Date])))-1
Esto me consiguió el resultado final calculado correctamente, pero cada fila todavía no se está calculando, simplemente reiterando los datos originales.
Gracias de nuevo por su ayuda.

Screenshot 2020-10-24 001150.png

Intente actualizar a algo como esto;

TCMCumulative&nbsp;test&nbsp;<br><span class>"Keyword" style&"color:#035aca">VAR</span>&nbsp;<span class<"Variable" style-"color:#49b0af">startDate>startDate>beginDate>beginDate>beginDate>beginDate>beginDate>beginDate>beginDate>beginDate>beginDate>beginDate>beginDate>beginDate>beginDate>beginDate>beginDate>beginDate>beginDate>beginDate>beginDate>beginDate>beginDate>beginDate>beginDate>beginDate>beginDate>beginDate>beginDate>beginDate>beginDate>beginDate>beginDate>begin lt;/span>&nbsp;<br><span class>"indent4">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class>"Keyword" style>"color:#035aca">> ;CALCULATE</span><span class-"Parenthesis" style>"color:#808080">&nbsp;(</span><br><span class>"indent8">&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class>"Keyword" style&"color:#035aca">MIN</span><span class<"Parenthesis" style>"color:"color:#035aca">MIN</span><span class<span class<"Parenthesis" style>"color"color:"color:#035aca">MIN</span><span class<span class<"Parenthesis" style>"color"color"color:">MIN</span><span class<span class<"Parenthesis" style>"color"color"color:"color:#035aca">MIN</ :#808080">&nbsp;(</span>&nbsp; TCMMonthlyReturnsInput[Fecha]&nbsp;<span class-"Parenthesis" style-"color:#808080">)</span>,<br><span class&"indent8">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&&nbsp nbsp;&nbsp;&nbsp;</span><span class-"Keyword" style-"color:#035aca">ALLSELECTED</span><span class&"Parenthesis" style"color:#808080">&nbsp;(</span&nbsp;&nbsp; TCMMonthlyReturnsInput[Date]&nbsp;<span class="Parenthesis" style="color:#808080">)</span><br><span class="indent4">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="Parenthesis" style="color:#808080">)</span><br><span class="Keyword" style="color:#035aca">RETURN</span><br><span class="indent4">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="Keyword" style="color:#035aca">CALCULATE</span><span class="Parenthesis" style="color:#808080">&nbsp;(</span><br><span class="indent8">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="Keyword" style="color :#035aca">PRODUCTX</span><span class-"Parenthesis" style-"color:#808080">&nbsp;(</span><br ><span class-"indent8">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<<<</span><span class-"indent4">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class-"Keyword" style-"color:"color:"color:"color:"color:#035aca">FILTER</span><span class-"Parenthesis" style-"color:#808080">&nbsp;(</span>&nbsp; TCMMonthlyReturnsInput,&nbsp;<span class-"Variable" style-"color:#49b0af">startdate</span>&nbsp;&lt;-&nbsp; TCMMonthlyReturnsInput[Fecha]&nbsp;<span class-"Parenthesis" style-"color:#808080">)</span>,<br><span class&"indent8">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& amp;nbsp;&nbsp;</span><span class>"indent4">&nbsp;&nbsp;&nbsp;&nbsp;</span>TCMMonthlyReturnsInput[MRTCM]&nbsp;+&nbsp;<clase-"Número #EE7F18" ">1</span><br><span class>"indent8">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class #808080>"Parenthesis" <2> <6>">)</span>,<br><span class&"indent8">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span:<span class>"Keyword" :#035aca">ALLSELECTED</span><span class-"Parenthesis" style-"color:#808080">&nbsp;(</span>&nbsp; TCMMonthlyReturnsInput[Fecha],&nbsp; TCMMonthlyReturnsInput[MRTCM]&nbsp;<span class-"Parenthesis" style-"color:#808080">)</span><br><span class>"indent4">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&&nbsp;&&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&&nbsp;&&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;>&nbsp;&&nbsp;&&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp lt;/span><span class&"Parenthesis" style>"color:#808080">)</span>&nbsp;-&nbsp;<span class>"Number" style>"color:#EE7F18">1</span><br>

Si eso sigue sin funcionar, ¿puede proporcionar datos de muestra?

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

AllisonKennedy
Super User
Super User

Deberá definir MAX(Date) como una variable antes de su ProductX, esto garantiza que obtenga la fecha máxima antes de agregar el contexto de fila que la función ProductX proporciona de fila por fila.

Esto también significa que es probable que tenga que experimentar con ALLSELECTED dentro de la variable MaxDate.

Háganos saber si necesita más información o recursos sobre variables, de lo contrario, esperemos que eso ayude.

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

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.