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

mantener el filtro ( ) + filtro ( todos ( ) )

Cortar:

Fecha[Fecha] - Oct 24, 2020 (sábado)

Informe:

UbicaciónProductoPrecio publicado
ChicagoManzanas1.25
ChicagoPlátano1.75
ChicagoZanahorias1.61

Tabla de productos:

UbicaciónProductoPrecio publicadoFecha
ChicagoManzanas1.2510/23/20
ChicagoManzanas2.1210/24/20
ChicagoManzanas2.5110/25/20
ChicagoPlátano1.7510/23/20
ChicagoPlátano2.6510/24/20
ChicagoPlátano2.7510/25/20
ChicagoZanahorias1.6110/23/20
ChicagoZanahorias2.4510/24/20
ChicagoZanahorias2.4110/25/20
Chicago Mango0.7510/23/20

posted price =
VAR WeekDays =
    IF ( HASONEVALUE ( Dates[Date] ), VALUES ( Dates[Day Short] ), "Mon" )
VAR SelDate =
    IF ( HASONEVALUE ( Dates[Date] ), VALUES ( Dates[Date] ), TODAY () )
VAR PostedPricesWeekday =
    CALCULATE (
        MIN ( 'Posted Prices'[Price] ),
        'Posted Prices'[Price Date]
            = IF ( HASONEVALUE ( Dates[Date] ), VALUES ( Dates[Date] ), TODAY () )
    )
VAR PostedPricesSat =
    CALCULATE (
        MIN ( 'Posted Prices'[Price] ),
        KEEPFILTERS (
            FILTER (
                ALL ( 'Posted Prices'[Price Date] ),
                'Posted Prices'[Price Date] = SelDate - 1
            )
        )
    )
VAR PostedPricesSun =
    CALCULATE (
        MIN ( 'Posted Prices'[Price] ),
        KEEPFILTERS (
            FILTER (
                ALL ( 'Posted Prices'[Price Date] ),
                'Posted Prices'[Price Date] = SelDate - 2
            )
        )
    )
RETURN
    IF (
        WeekDays = "Sat",
        PostedPricesSat,
        IF ( WeekDays = "Sun", PostedPricesSun, PostedPricesWeekday )
    )

Hay una relación de muchos a 1 entre la tabla de productos [fecha] y la fecha [fecha].

A pesar de que la cortadora dice 10/24/2020, quiero mostrar el último precio de día de la semana disponible, que es 10/23/2020 (viernes) en este caso. He incluido filter ( all ( ) ) en mi medida, de lo contrario, el contexto de filtro 10/24/2020 solo devolvería el valor del sábado. Sin embargo, todavía me gustaría mantener el contexto de filtro para la ubicación y el producto porque de lo contrario mi medida devolvería 0.75 (de mangos). Intenté usar Keepfilters, pero no estoy logrando el resultado deseado.

¿Ayuda?

1 ACCEPTED SOLUTION
smpa01
Super User
Super User

@eddd83 no sé si te gustaría, pero lo resolví usando una medida diferente.

Revised Price := 
VAR _1 = MAX(Dates[Date])
VAR _2 = CALCULATE(MAX(Dates[Date]),FILTER(ALL(Dates),Dates[Date]<=_1&&[Max Revised date]<>0))
VAR _3 = CALCULATE([MaxPrice],ALL(Dates[Date]),Dates[Date]=_2)
RETURN _3

solve.PNG

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

View solution in original post

5 REPLIES 5
smpa01
Super User
Super User

@eddd83 no sé si te gustaría, pero lo resolví usando una medida diferente.

Revised Price := 
VAR _1 = MAX(Dates[Date])
VAR _2 = CALCULATE(MAX(Dates[Date]),FILTER(ALL(Dates),Dates[Date]<=_1&&[Max Revised date]<>0))
VAR _3 = CALCULATE([MaxPrice],ALL(Dates[Date]),Dates[Date]=_2)
RETURN _3

solve.PNG

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

@eddd83 que hizo probar la solución proporcionada?

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
amitchandak
Super User
Super User

@eddd83, no muy claro. Puede tener una tabla de fechas con las siguientes columnas

WeekDay - WEEKDAY([Fecha],2) //monday
Inicio de la semana [Fecha] -[WeekDay]+1 //monday
Rango de la semana - RANKX(all('Date'),'Date'[Week Start date],,ASC,Dense)

Medidas ?

var _max á maxx(allselected('Date'), 'Date'[Week Rank])

devolución

Calculate(min(Produce[Posted Price]) , filter(All('Date'), 'Date'[Week Rank]) á _max))

Para obtener lo mejor de la función de inteligencia del tiempo. Asegúrese de que tiene un calendario de fechas y que se ha marcado como la fecha en la vista de modelo. Además, únete a ella con la columna de fecha de tus hechos. Consulte :radacad sqlbi My Video Series Aprecia tus Felicitaciones.

@amitchandak

lo siento por la confusión. Por favor, vea el enlace de una unidad con mi archivo:

https://onedrive.live.com/?authkey=%21APgzM8jL%2DrliMyw&cid=69E558AB6771FF6A&id=69E558AB6771FF6A%211...

Básicamente mi medida (precio publicado) funciona para los días de la semana, pero devuelve un espacio en blanco para los fines de semana. Idealmente para los días de la semana, se mostraría el viernes anterior (10/23) en este escenario.

Hola @eddd83 ,

Puede crear una nueva columna de día de la semana en la tabla Fecha:

weekday = WEEKDAY(Dates[Date],2)

Capture4.PNG

A continuación, utilice REMOVEFILTER para borrar el filtro de la segmentación en[precio registrado]:

_posted price = var a = IF(SELECTEDVALUE(Dates[weekday])<=5,MAX(Dates[Date]),CALCULATE(MAX(Dates[Date]),FILTER(ALL(Dates),Dates[Date]<=MAX(Dates[Date])&&Dates[weekday]<=5))) return CALCULATE(MIN('Posted Prices'[Price]),'Posted Prices'[Price Date] = a,REMOVEFILTERS(Dates[Date])) 

Capture5.PNG

Para obtener más información, consulte el archivo pbix: https://qiuyunus-my.sharepoint.com/:u:/g/personal/pbipro_qiuyunus_onmicrosoft_com/EUfmRSl0n3VLrP3tbk...

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

Saludos

Dedmon Dai

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.