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
Minakshi
Resolver I
Resolver I

DAX para el top 2 de 4 semanas

Hola a todos

Tengo una mesa como esta

nombre de la tiendanombre del clienteSemanapurchace
Vikas Gen StoreRohit7/9/2020100
Vikas Gen StoreMohit7/9/2020150
Vikas Gen StoreSohan14/9/2020200
Vikas Gen StoreMohan14/9/202010
Vikas Gen StoreVikas21/9/2020250
Vikas Gen StoreRohit29/9/202010
Vikas Gen StoreRohan 21/9/202020
Vikas Gen StoreVikas29/9/202020

Como resultado, espero, top 2 semanas (orden descendente) que están teniendo la máxima purchage individual.

Da la siguiente tabla como salida

Vikas Gen StoreSohan 14/9/2020200
Vikas Gen Store Vikas21/9/2020250

y finalmente da

Tienda Vikas Gen 450

Por favor, ayúdame con la expresión DAX.

Gracias de antemano

1 ACCEPTED SOLUTION

@Fowmy Solucioné el problema con groupby con Week y tomando el máximo de él. Gracias una vez más por su ayuda

View solution in original post

8 REPLIES 8
Fowmy
Super User
Super User

@Minakshi

Utilice esta medida por favor:


TiendaTop 2 Total
Vikas Gen Store450



Top 2 Total = 

CALCULATE(
    SUM(Table4[purchace]),
    TOPN( 2 , Table4 , Table4[purchace] ,DESC)
)

________________________

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

amitchandak
Super User
Super User

@Minakshi , Probar como

//2 measures
PO = SUM(Top2[purchace])
Top 2 Rank = CALCULATE([PO],TOPN(2,all(Top2),[PO],DESC),VALUES(Top2))

Para Rango Referir
https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures

@amitchandak, @Fowmy parece que el top 2 no funciona cuando hay 2 compras con la misma cantidad en la misma semana. Los suma. Sólo necesito una compra de dos, incluso si son iguales.

Por favor, ayúdame con esto.

@Minakshi 

Can you try this revised measure?

Top 2 Total = 
SUMX(
    TOPN( 
        2 ,  
        SUMMARIZE( Table4 , Table4[shop name],Table4[week], "_Max", MAX(Table4[purchace])), 
        [_Max] ,DESC,Table4[week]
    ), 
    [_Max]
)

 

________________________

If my answer was helpful, please consider Accept it as the solution to help the other members find it

Click on the Thumbs-Up icon if you like this reply 🙂

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

Muchas gracias por sus esfuerzos @Fowmy ., @amitchandak . Pero mi problema sigue sin resolverse, en caso de que no haya visitas excepto 2 visitas en la misma semana. Suma ambos visite, pero quiero la primera 1 visita de 2 visitas de una semana.

Gracias

@Minakshi

¿Puede preparar una muestra con el resultado esperado, incluidos los escenarios que está explicando aquí?

________________________

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

@Fowmy Solucioné el problema con groupby con Week y tomando el máximo de él. Gracias una vez más por su ayuda

@Minakshi ,

La primera medida sigue siendo la misma. Usa estos dos. El tercero es el que necesitas en visual

Top2 Rank = rankx(ALL(Top2),[PO],,DESC,Dense) + RAND()/1000
Top 2 Shop Rank = CALCULATE([PO],TOPN(2,all(Top2),[Top2 Rank],ASC),VALUES(Top2))

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.