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
PabloGiraldo
Helper IV
Helper IV

Filtrar y calcular porcentajes

Hola a todos

Tengo la siguiente tabla con mahours que se actualizan semanalmente y mensualmente. Basado en el "Total MH Forecasted" que se actualizan mensualmente, quiero ser capaz de filtrar / hacer clic de alguna manera en una tarjeta que me dará % Completado hasta la fecha cada semana cuando los datos se actualizan.

Así que si tuviera que enviar una actualización el 11/7/2020, Me gustaría que el filtro/tarjeta utilizara el último valor "Total MH Forescated" (en este caso 995,156) y 1) Divide por la suma de cada Categoría ("Gestión," "Campo", etc.) para obtener % Completado a Fecha por Categoría y 2) Dividir por la Suma Total de todas las Categorías para obtener el % Total Completado hasta la Fecha.

Abierto a cualquier idea sobre cómo se podría presentar esto

.Capture.JPG

Gracias

Pablo

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

Hola, @PabloGiraldo

Según su descripción, creé datos para reproducir su escenario. El archivo pbix se adjunta al final.

Mesa:

b1.png

Fecha (una tabla calculada):

Date = DISTINCT('Table'[Week Ending])

Puede crear tres medidas como se indica a continuación.

Management measure = 
IF(
    HASONEVALUE('Date'[Week Ending]),
    IF(
        ISFILTERED('Table'[Week Ending]),
        SUM('Table'[Management]),
        DIVIDE(
            CALCULATE(
                SUM('Table'[Management]),
                FILTER(
                    ALL('Table'),
                    [Week Ending]<=SELECTEDVALUE('Date'[Week Ending])
                )
            ),
            CALCULATE(
                SUM('Table'[Total MH Forecasted]),
                FILTER(
                    ALL('Table'),
                    [Week Ending]=
                    CALCULATE(
                        MAX('Table'[Week Ending]),
                        FILTER(
                            ALL('Table'),
                            [Week Ending]<=SELECTEDVALUE('Date'[Week Ending])&&
                            [Total MH Forecasted]>0
                        )
                    )
                )
            )
        )
    )
)
Field measure = 
IF(
    HASONEVALUE('Date'[Week Ending]),
    IF(
        ISFILTERED('Table'[Week Ending]),
        SUM('Table'[Field]),
        DIVIDE(
            CALCULATE(
                SUM('Table'[Field]),
                FILTER(
                    ALL('Table'),
                    [Week Ending]<=SELECTEDVALUE('Date'[Week Ending])
                )
            ),
            CALCULATE(
                SUM('Table'[Total MH Forecasted]),
                FILTER(
                    ALL('Table'),
                    [Week Ending]=
                    CALCULATE(
                        MAX('Table'[Week Ending]),
                        FILTER(
                            ALL('Table'),
                            [Week Ending]<=SELECTEDVALUE('Date'[Week Ending])&&
                            [Total MH Forecasted]>0
                        )
                    )
                )
            )
        )
    )
)
SubA measure = 
IF(
    HASONEVALUE('Date'[Week Ending]),
    IF(
        ISFILTERED('Table'[Week Ending]),
        SUM('Table'[SubA]),
        DIVIDE(
            CALCULATE(
                SUM('Table'[SubA]),
                FILTER(
                    ALL('Table'),
                    [Week Ending]<=SELECTEDVALUE('Date'[Week Ending])
                )
            ),
            CALCULATE(
                SUM('Table'[Total MH Forecasted]),
                FILTER(
                    ALL('Table'),
                    [Week Ending]=
                    CALCULATE(
                        MAX('Table'[Week Ending]),
                        FILTER(
                            ALL('Table'),
                            [Week Ending]<=SELECTEDVALUE('Date'[Week Ending])&&
                            [Total MH Forecasted]>0
                        )
                    )
                )
            )
        )
    )
)

Por último, puede usar el 'Week Ending' de 'Date' para filtrar el resultado.

b2.png

Saludos

Allan

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

View solution in original post

8 REPLIES 8
v-alq-msft
Community Support
Community Support

Hola, @PabloGiraldo

Según su descripción, creé datos para reproducir su escenario. El archivo pbix se adjunta al final.

Mesa:

b1.png

Fecha (una tabla calculada):

Date = DISTINCT('Table'[Week Ending])

Puede crear tres medidas como se indica a continuación.

Management measure = 
IF(
    HASONEVALUE('Date'[Week Ending]),
    IF(
        ISFILTERED('Table'[Week Ending]),
        SUM('Table'[Management]),
        DIVIDE(
            CALCULATE(
                SUM('Table'[Management]),
                FILTER(
                    ALL('Table'),
                    [Week Ending]<=SELECTEDVALUE('Date'[Week Ending])
                )
            ),
            CALCULATE(
                SUM('Table'[Total MH Forecasted]),
                FILTER(
                    ALL('Table'),
                    [Week Ending]=
                    CALCULATE(
                        MAX('Table'[Week Ending]),
                        FILTER(
                            ALL('Table'),
                            [Week Ending]<=SELECTEDVALUE('Date'[Week Ending])&&
                            [Total MH Forecasted]>0
                        )
                    )
                )
            )
        )
    )
)
Field measure = 
IF(
    HASONEVALUE('Date'[Week Ending]),
    IF(
        ISFILTERED('Table'[Week Ending]),
        SUM('Table'[Field]),
        DIVIDE(
            CALCULATE(
                SUM('Table'[Field]),
                FILTER(
                    ALL('Table'),
                    [Week Ending]<=SELECTEDVALUE('Date'[Week Ending])
                )
            ),
            CALCULATE(
                SUM('Table'[Total MH Forecasted]),
                FILTER(
                    ALL('Table'),
                    [Week Ending]=
                    CALCULATE(
                        MAX('Table'[Week Ending]),
                        FILTER(
                            ALL('Table'),
                            [Week Ending]<=SELECTEDVALUE('Date'[Week Ending])&&
                            [Total MH Forecasted]>0
                        )
                    )
                )
            )
        )
    )
)
SubA measure = 
IF(
    HASONEVALUE('Date'[Week Ending]),
    IF(
        ISFILTERED('Table'[Week Ending]),
        SUM('Table'[SubA]),
        DIVIDE(
            CALCULATE(
                SUM('Table'[SubA]),
                FILTER(
                    ALL('Table'),
                    [Week Ending]<=SELECTEDVALUE('Date'[Week Ending])
                )
            ),
            CALCULATE(
                SUM('Table'[Total MH Forecasted]),
                FILTER(
                    ALL('Table'),
                    [Week Ending]=
                    CALCULATE(
                        MAX('Table'[Week Ending]),
                        FILTER(
                            ALL('Table'),
                            [Week Ending]<=SELECTEDVALUE('Date'[Week Ending])&&
                            [Total MH Forecasted]>0
                        )
                    )
                )
            )
        )
    )
)

Por último, puede usar el 'Week Ending' de 'Date' para filtrar el resultado.

b2.png

Saludos

Allan

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

@v-alq-msft

¿Es posible modificar las medidas para poder llegar al mes hasta la fecha y al año hasta la fecha? En este momento las medidas nos dan Total Proyecto hasta la Fecha.

¡Gracias!

Gracias. No estoy seguro de cómo llegaste aquí, pero fue muy útil.

ToddChitt
Super User
Super User

@PabloGiraldo ¿Puedes explicar un poco más?

¿Estoy entendiendo esto correctamente:

Dado un segmento de fecha de 10/17/2020, desea dividir la SUMA de horas de administración HASTA A TRAVES de esa fecha por el último valor NO CERO de la segunda columna.

Por lo tanto: 3 * 600 + 5 * 640 á 5000

5000 / 995156 a .005024

¿Es eso correcto?




Did I answer your question? If so, mark my post as a solution. Also consider helping someone else in the forums!

Proud to be a Super User!





No. Todavía quiero incluir todas las horas de administración hasta 11/7/2020 y dividir por el valor LAS NON-ZERO de la segunda columna.

Por lo tanto: 3 * 600 + 5 * 640 + 680 +720 +800 á 7200

7200 / 995156 a .00723

¡Gracias!

Ah, estás hablando de una porción de fecha de 11/7 y yo estaba hablando de 10/17.

Tus matemáticas tienen sentido.

Atacaría esto en dos partes, luego los uniría:

Pronóstico más reciente: CALCULATE ( LASTNONBLANK ( [Previsión total de MH] ), [Pronóstico MH total] <> 0 )

FUNCIÓN LASTNONBLANK (DAX) - DAX ? Documentos de Microsoft

Entonces:

Horas de gestión de YTD : TOTALYTD ( SUM(Managemnt), Dates[Date] )

(Esto supone que tiene una dimensión Fecha adjunta.

Finalmente:

Porcentaje completado: DIVIDE ( [Pronóstico más reciente], [Horas de administración de YTD], 0 )

Pruébelo agregando estas medidas a una tabla ordenada por fecha/semana para comprobar la lógica de cada una.

Espero que esto ayude.




Did I answer your question? If so, mark my post as a solution. Also consider helping someone else in the forums!

Proud to be a Super User!





No hay suerte aquí. No funcionó.

Me gustaría tener todos mis datos en una tabla y luego usar un filtro que me dará % Completado a Fecha valor.

Gracias.

Voy a darle una oportunidad en los próximos 30 minutos y responder a ver si funcionó.

¡Gracias!

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.