This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. We're covering it all. You won't want to miss it.
Learn moreLevel up your Power BI skills this month - build one visual each week and tell better stories with data! Get started
Hola
Estoy tratando de lograr una medida en la que se debe mostrar el precio del mes seleccionado, si el precio no está disponible en ese mes, entonces debería mostrar el siguiente precio disponible
He utilizado un calendario de desvinculación para la selección de referencia Mes Año
Este es el requisito:
| Material | planta | Cliente | Fecha | Precio de venta | Precio de referencia 1-03-2020 |
| M0001 | P001 | CSM001 | 01-01-2020 | 90 | 69 |
| M0001 | P001 | CSM001 | 01-02-2020 | 89 | 69 |
| M0001 | P001 | CSM001 | 01-03-2020 | 69 | 69 |
| M0001 | P001 | CSM001 | 01-06-2020 | 90 | 69 |
| M0001 | P001 | CSM001 | 01-07-2020 | 18 | 69 |
| M0001 | P001 | CSM001 | 01-08-2020 | 82 | 69 |
| M0001 | P001 | CSM001 | 01-09-2020 | 56 | 69 |
| M0002 | P001 | CSM001 | 01-01-2020 | 90 | 64 |
| M0002 | P001 | CSM001 | 01-02-2020 | 99 | 64 |
| M0002 | P001 | CSM001 | 01-07-2020 | 64 | 64 |
| M0002 | P001 | CSM001 | 01-08-2020 | 22 | 64 |
La medida que estoy tratando de construir:
ReferencePrice = VAR ReferencePeriod = [ReferencePeriod]
VAR ReferenceTable =
RESUMIR (
CALCULATETABLE ( 'Tabla', 'Tabla'[Fecha] >= ReferencePeriod, REMOVEFILTERS(Date)),
'Mesa' [Planta],
«Tabla» [material],
«Mesa» [Cliente],
"SalesPrice",
Precio VAR =
CALCULAR (
MAX ( 'Tabla' [Precio de venta] ),
'Tabla'[Fecha] = ReferencePeriod,
REMOVEFILTERS ( DimDate )
)
DONDE PriceMPlus1 =
CALCULAR (
MAX ( 'Tabla' [Precio de venta] ),
'Tabla'[Fecha] = EDATE ( ReferencePeriod, 1 ),
REMOVEFILTERS ( DimDate )
)
DONDE PriceMPlus2 =
CALCULAR (
MAX ( 'Tabla' [Precio de venta] ),
'Tabla'[Fecha] = EDATE ( ReferencePeriod, 2 ),
REMOVEFILTERS ( DimDate )
)
Precio VARMlus3 =
CALCULAR (
MAX ( 'Tabla' [Precio de venta] ),
'Tabla'[Fecha] = EDATE ( ReferencePeriod, 3 ),
REMOVEFILTERS ( DimDate )
)
DEVOLUCIÓN
INTERRUPTOR (
VERDADERO (),
NO ( ISBLANK ( Precio ) ), Precio,
ISBLANK ( Precio ), PriceMPlus1,
ISBLANK ( PriceMPlus1 ), PriceMPlus2,
ISBLANK ( PriceMPlus2 ), PriceMPlus3,
Precio
)
)
DEVOLUCIÓN
SUMX ( ReferenceTable, [SalesPrice] )
¡Gracias por su rápida respuesta!
De acuerdo con su descripción, desea mostrar todo en su tabla .
Puedes intentar usar este código dax:
Measure = var _slicer = MIN('Calendar'[Date])
var _material= MAX('Table'[Material])
var _has_value =MAXX( FILTER(ALLSELECTED('Table') , 'Table'[Date]=_slicer && 'Table'[Material]=_material) , [Sales Price])
var _no_value_date = MINX( FILTER(ALLSELECTED('Table') , 'Table'[Date]>_slicer && 'Table'[Material]=_material) , [Date])
var _no_value =MAXX( FILTER(ALLSELECTED('Table') , 'Table'[Date] = _no_value_date && 'Table'[Material]=_material) , [Sales Price])
return
IF(_has_value=BLANK(),_no_value,_has_value)
Gracias por su tiempo y uso compartido, y gracias por su apoyo y comprensión de PowerBI.
Saludos
Dijo Zhang
Si esta publicación ayuda, considere Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.
Hola
Gracias por la respuesta, fue muy útil y ha resuelto el problema en un 90%, el precio debe repetirse para todos los meses / fecha como mostrar en Img 2.
He intentado usar AllExcept funtion y All funtion para evitar el filtro Date But no Luck.
IMG 1
Img 2
De acuerdo con su descripción, desea lograr una medida en la que se debe mostrar el precio del mes seleccionado, si el precio no está disponible en ese mes, debe mostrar el siguiente precio disponible.
Estos son los pasos que puede consultar:
(1) Estos son mis datos de prueba:
Creo una tabla de calendario como esta:
(2) Podemos crear una medida como esta:
Measure = var _slicer = MIN('Calendar'[Date])
var _has_value =MAXX( FILTER( 'Table' , 'Table'[Date]=_slicer) , [Sales Price])
var _no_value_date = MINX( FILTER('Table' , 'Table'[Date]>_slicer) , [Date])
var _no_value =MAXX( FILTER('Table' , 'Table'[Date] = _no_value_date) , [Sales Price])
return
IF(_has_value=BLANK(),_no_value,_has_value)
(3) Entonces podemos poner la medida en lo visual y podemos satisfacer su necesidad:
Gracias por su tiempo y uso compartido, y gracias por su apoyo y comprensión de PowerBI.
Saludos
Dijo Zhang
Si esta publicación ayuda, considere Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.
Check out the April 2026 Power BI update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.