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
Franco_RV
Frequent Visitor

Dax nombres distintos a columnas en base a selección de fecha

Saludos comunidad!

 

necesito de vuestra ayuda para resolver la siguiente situación:

 

poseo un dataset similar a este: 

 

Franco_RV_0-1600730137741.png

 

el objetivo que se me ha planteado es obtener a base de una selección de id_product en una fecha especifica, obtener una matriz o tabla similar a esto (ver imagen) suponiendo que selecciono el valor para la fecha '17/09/2020' :

 

Franco_RV_1-1600730436728.png

 

el resultado debe ser la trasposición en base a la fecha  o producto seleccionado y contar 7 días anteriores asignando los valores de campo como muestra en la imagen(o similar), si bien esto he logrado realizarlo mezclando los filtros de objeto en la matriz resultante con un top 7 de los registros, no logro modificar el valor de nombre para cada día. que solución me sugieren?

un aspecto que me lo hace más díficil es que no siempre son fechas consecutivas, hay alguna forma de rellenar estas fechas con valor 0?

 

se agradece cualquier información y aporte

 

 

 
1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

That's a good dataset structure.  You can get your result with TOPN(7) and some filters.  Be aware that the Top 7 results before a given date are different for each product. Do you need to show results for multiple products in the same visual?

 

Here is some meta code for the simple scenario (single product). Note: use a disconnected dates table to feed the slicer.

 

 

Include := 
var p = selectedvalue(visual[product])
var vd = selectedvalue(values[date])
var sd = selectedvalue(slicer[date])
var r = calculatetable(TOPN(7,values[date],,desc),date<sd,product=p,value>0)
var i = intersect(r,vd)
return countrows(i)>0

 

 

 

 

View solution in original post

2 REPLIES 2
lbendlin
Super User
Super User

That's a good dataset structure.  You can get your result with TOPN(7) and some filters.  Be aware that the Top 7 results before a given date are different for each product. Do you need to show results for multiple products in the same visual?

 

Here is some meta code for the simple scenario (single product). Note: use a disconnected dates table to feed the slicer.

 

 

Include := 
var p = selectedvalue(visual[product])
var vd = selectedvalue(values[date])
var sd = selectedvalue(slicer[date])
var r = calculatetable(TOPN(7,values[date],,desc),date<sd,product=p,value>0)
var i = intersect(r,vd)
return countrows(i)>0

 

 

 

 

It has been a great help!! although finally the client opted for another visualization it is a good idea to implement in the future!!

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.

Top Solution Authors