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
Kevin_Gitonga
Helper I
Helper I

Resumir la función Perfomance

Tengo este modelo Dimension Tables of Branches, Products and Dates, y una tabla de hechos de Stocks and Sales.

dax question.PNG

Necesito contar el número de productos por sucursal por día donde el stock estaba por debajo del nivel de búfer.

Tengo la medida folllowing que funciona, sin embargo, toma mucho tiempo para calcular a menudo usando una gran cantidad de memoria. ¿Hay alguna manera de optimizar la velocidad de esta medida para que pueda trazarla en un gráfico de líneas y usarla en una tabla sin un consumo intensivo de recursos?

Below Buffer SKUs = 
CALCULATE(
    COUNTROWS(
        FILTER(            
            SUMMARIZE(
                CROSSJOIN(VALUES(pbi_Products[Code]),VALUES(pbi_Branches[Branch]),VALUES(Dates[Date])),
                pbi_Branches[Branch],pbi_Products[Code],Dates[Date],
                "Active Products",[Sales P3M],
                "vs Buffer",[Stock vs Buffer]
                ),
            [Active Products]>0 &&[vs Buffer]<0
        )
    )
)

8 REPLIES 8
parry2k
Super User
Super User

@Kevin_Gitonga no está seguro de cómo está visualizando los datos, vamos a ir muy básico aquí, usar columnas de la tabla de dimensiones y la agregación de cada tabla, en el objeto visual de la tabla y debe obtener la información correcta y desde allí podemos construir la lógica de negocios.



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.

Bien, así es como estoy visualizando los datos donde para cada día, sucursal y código de producto destaco los productos donde el stock vs búfer es menor que 0 como se indica en rojo. La lógica de negocios debe llegar a una relación para esto que cuente el número de productos para cada día en cada rama donde el stock vs buffer es menor que 0.

por ejemplo, en esta captura de pantalla el conteo sería 3

buff 2.PNG

@Kevin_Gitonga qué son las acciones y el búfer, ¿son estas medidas? ¿Puede compartir el archivo pbix para obtener la solución? Retire cualquier sensitivie antes de compartir



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.

Hola @Kevin_Gitonga ,

Podemos optimizarlo de la siguiente manera:

Measure 3 = 
var temp = CROSSJOIN(VALUES(pbi_Branches[Branch]),VALUES(pbi_Products[Code]))
return
   SUMX(GROUPBY('Dates','Dates'[Date]),CALCULATE(COUNTROWS(FILTER(temp,
                CALCULATE ( [Sales P3M] ) > 0
                    && CALCULATE ( [Stock vs Buffer] ) < 0
            ))))

Measure 4 = 
VAR temp =
    CROSSJOIN (
        VALUES ( pbi_Products[Code] ),
        VALUES ( pbi_Branches[Branch] ),
        VALUES ( Dates[Date] )
    )
RETURN
    CALCULATE (
        COUNTROWS (
            FILTER (
                temp,
                CALCULATE ( [Sales P3M] ) > 0
                    && CALCULATE ( [Stock vs Buffer] ) < 0
            )
        )
    )

1.jpg

Pero observe porque el objeto visual de tabla enumerará todo el resultado posible para que el objeto visual de la tabla consuma mucho recurso, incluso no use esta medida.


Saludos

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-lid-msft lamenta decir, pero eso no es una solución, medir tomando por encima de 70000ms, es doloroso y especialmente en este conjunto de datos más pequeño, necesita volver a visitar su solución.

@Kevin_Gitonga Tuve la oportunidad de ver su informe y he ajustado algunas de las medidas, pero no tuve suficiente tiempo para revisar todo esto, pero seguramente puede funcionar mucho más rápido que lo que ya tiene. Voy a tratar de volver a esto lo antes posible, requiere un poco de depuración y tengo que mirar cada medida como hay dependencia.



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.

@parry2k Bien

Hola @parry2k ,

Sí, tiene razón, el tiempo de ejecución de los años 70 no puede ser una solución válida, lo revisé de nuevo, arreglé una función mediax, pero todavía necesita 50s para ejecutarse durante todo el año. Debido a que necesita calcular la condición para cada fecha y hora, marca y código (alrededor de 1,6M posible año entero), no tengo idea de cómo optimizar más, mirando hacia adelante para ver una solución maravillosa de usted.

Measure 3 = 
VAR temp =
    CROSSJOIN ( VALUES ( pbi_Branches[Branch] ), VALUES ( pbi_Products[Code] ) )
RETURN
    SUMX (
        DISTINCT ( 'Dates'[Date] ),
        VAR d = 'Dates'[Date]
        VAR m3d =
            EDATE ( d, -3 ) + 1
        RETURN
            CALCULATE (
                COUNTROWS (
                    FILTER (
                        temp,
                        CALCULATE (
                            SUM ( 'pbi_Sales'[Qty] ),
                            ALL ( Dates[Date] ),
                            'Dates'[Date] >= m3d,
                            'Dates'[Date] <= d
                        ) > 0
                            && CALCULATE (
                                SUM ( pbi_SkuQuantity[Qty] ),
                                ALL ( Dates[Date] ),
                                'Dates'[Date] <= d
                            )
                                < DIVIDE (
                                    CALCULATE (
                                        SUM ( pbi_Sales[Qty] ),
                                        ALL ( Dates[Date] ),
                                        'Dates'[Date] >= m3d,
                                        'Dates'[Date] <= d
                                    ),
                                    CALCULATE (
                                        DISTINCTCOUNT ( pbi_Sales[InvDate] ),
                                        ALL ( Dates[Date] ),
                                        'Dates'[Date] >= m3d,
                                        'Dates'[Date] <= d
                                    )
                                ) * 2
                    )
                )
            )
    )


Saludos

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.