Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
PatrickWong
Helper I
Helper I

llenar en blanco para los valores sat /sun

Pude descargar el precio de las acciones de un contador en particular de Yahoo.finance. tendrá una columna de fecha y el precio de cierre de una acción (para que sea simple). habrá 5 filas de datos y luego la fecha se saltará 2 días (sat y Sol) y repetirá.

También he creado una tabla de calendario con fechas justas

A continuación, vinculo las fechas del calendario con las fechas de stock.

Cuando creo una tabla de informe con fecha de calendario en la primera columna y el precio de cierre en la segunda columna, la tabla mostrará 5 días de precio de stock y luego 2 filas de espacios en blanco.

¿Cómo puedo tener la celda en blanco 2 rellenada con el anterior

1 ACCEPTED SOLUTION
PaulDBrown
Community Champion
Community Champion

@PatrickWong

Prueba esto y mira si funciona.

1) Crear una medida de suma para el precio de la acción

Stock Price = SUM(Table[Stock Price])

2) Para rellenar los espacios en blanco

Stock Price Blank filled = 
VAR _lastdate = MAXX(
                FILTER(ALL(Date Table), 
                 Date Table[Date] <= MAX(Date Table[Date]) 
                 && NOT(ISBLANK([Stock Price]))), 
                  Date Table[Date])
RETURN
CALCULATE([Stock Price], 
    FILTER(ALL(Date Table), 
      Date Table[Date] = _lastdate))




Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

6 REPLIES 6
PaulDBrown
Community Champion
Community Champion

@PatrickWong

Prueba esto y mira si funciona.

1) Crear una medida de suma para el precio de la acción

Stock Price = SUM(Table[Stock Price])

2) Para rellenar los espacios en blanco

Stock Price Blank filled = 
VAR _lastdate = MAXX(
                FILTER(ALL(Date Table), 
                 Date Table[Date] <= MAX(Date Table[Date]) 
                 && NOT(ISBLANK([Stock Price]))), 
                  Date Table[Date])
RETURN
CALCULATE([Stock Price], 
    FILTER(ALL(Date Table), 
      Date Table[Date] = _lastdate))




Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






HI PaulDBrown

Esto es exactamente lo que se necesitaba. Gracias

@PatrickWong

¡Gran!

¿Puede marcar el post relevante como una solución para cerrar el hilo y ayudar a otros que buscan una solución similar?

Gracias.





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






PatrickWong
Helper I
Helper I

HI Speedramp, thank for the solution, it would probably work but as we load more stocks table, this becomes very troublesome. I would prefer that we implement some DAX formula so that it is more elegant and more scaleable. 

 

Hi again Patrick

 

Please consider this solution and leave kudos

 

Click here for PBIX example 

 

Create a Calendar table with a list of all dates, the day name and day offset counter.

 

Create your Yahoo table of prices for each day except sat and sun.

 

Create a one to many relationship between calendar[date] and Yahoo[date].

 

Create this dax measure and create a report by calendar[date] for the measure.
It uses a CALCULATE with ALL to remove the current date context and then a offset to get Friday’s prices for sat and sun.

 

Note you need to improve the logic for midweek holidays.

 

 

myprice =

VAR dayofweek = SELECTEDVALUE('Calendar'[Day Of Week])

VAR offset = SELECTEDVALUE('Calendar'[DayOffset])

RETURN

SWITCH(TRUE(),

dayofweek = "Saturday",
CALCULATE(MAX(Yahoo[Price]),ALL('Calendar'),'Calendar'[DayOffset] = offset -1 ),

dayofweek = "Sunday",
CALCULATE(MAX(Yahoo[Price]),ALL('Calendar'),'Calendar'[DayOffset] = offset - 2 ),

MAX(Yahoo[Price])

)

 

speedramps
Super User
Super User

Por favor considere esta solución.

Duplica la tabla de calendario, elimina todas las filas excepto sat y sun y elimina todas las columnas excepto la fecha.

Así que tienes una lista de sólo sentarse y salir al sol.

Llama a la mesa "Fines de semana".

Añade "Weekends" en tu mesa de Yahoo.

Ordene el bronceado por fecha.

Utilice la transformación Rellenar para rellenar los precios vacíos (para sat y sun) con el precio anterior.

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.