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
Syndicate_Admin
Administrator
Administrator

Crear medida a partir de la tabla de hechos

Tengo una tabla de hechos como la siguiente y el requisito es SalesTarget para algunos ProductdID, OpportunityRecordTypeID y StageID

FactTable:

Babulal_0-1633373217628.png

SalesTarget for few Product, OpportunityRecordType y Stage:

Babulal_4-1633374918662.png

Estoy buscando una medida que se pueda agregar como SUM de SalesTarget se puede lograr en visuales similares a SQL como

Babulal_3-1633374163393.png

O cualquier otra idea que pueda resolver el problema.

11 REPLIES 11
Syndicate_Admin
Administrator
Administrator

Puede reescribir el SQL con SWITCH ( TRUE, ... ).

SwitchTrue =
SWITCH (
    TRUE,
    Table1[ProductID]
        IN { 4, 6, 11, 34, 35, 38, 43, 44, 45 }
        && Table1[OpportunityRecordTypeID] = 11
        && Table1[StageID] IN { 7, 8, 10, 12, 15, 17, 18, 24, 28 }, 1492601,
    Table1[ProductID]
        IN { 4, 5, 6, 7, 8, 9, 11 }
        && Table1[OpportunityRecordTypeID] = 2
        && Table1[StageID] IN { 2, 13, 14, 16, 19, 29 }, 8857013,
    [etc.]
)

Hola @AlexisOlson,probé esto y llegué a saber que Switch funciona en medidas pero no en columnas de tabla.

¿Eh? Esperaría que lo que escribí funcionara como una columna calculada, pero no como una medida, ya que hace referencia a los valores de fila en lugar de a los agregados de columnas. Switch puede funcionar con cualquiera de los dos, pero el resto de la sintaxis debe ser correcta.

Sí, @AlexisOlson, la sintaxis es con lo que estoy luchando.

¿Puede por favor hacerme saber cómo escribir para la columna Calculado

@Babulal ¿Puede proporcionar algunos datos de ejemplo en un formulario de tabla que no sea imagen?

Hola @smpa01 , agregando 20 filas de datos.

OpportunityID	OpportunityRecordTypeID	OwnerRoleID	ProductID	StageID	TypeID	ForecastCategoryID	AccountID	CategoryID	LostReasonID
1	1	4	1	5	8	7	1	1	1
1	1	7	1	5	8	7	1	1	1
1	1	7	1	14	8	7	1	1	1
1	1	7	1	16	8	7	1	1	1
1	1	7	1	2	8	8	1	1	1
1	1	4	1	16	8	8	1	1	1
1	1	7	1	16	8	8	1	1	1
1	1	7	1	16	9	8	1	1	1
1	1	7	1	16	3	7	1	1	1
1	1	7	1	21	3	7	1	1	1
1	1	7	1	2	3	8	1	1	1
1	1	7	1	16	3	8	1	1	1
1	1	7	1	22	4	5	1	1	1
1	1	7	1	3	4	7	1	1	1
1	1	7	1	4	4	7	1	1	1
1	1	7	1	5	4	7	1	1	1
1	1	8	1	7	5	2	1	1	1
1	1	4	1	6	5	4	1	1	1
1	1	8	1	6	5	4	1	1	1
1	1	8	1	8	5	5	1	1	1

@Babulal lo investigó y también investigó la solución de @AlexisOlson. Esa solución es buena.

smpa01_0-1633441529381.png

Gracias @smpa01 y @AlexisOlson por su tiempo en esto, estoy trabajando en la implementación de esta solución que mencionó y evaluar el resultado.

¿Puedo hacer una consulta más, ¿Hay alguna manera de asignar valores a Switch DAX usando tablas de dimensiones? gustar

SWITCH(TRUE(),'DBO DIMProduct'[ProductName] IN {'OutputServices','Realtime'} && 'DBO DIMOpportunityRecordType'[OpportunityName] = "New Client", 1234,....

No @Babulal,

Si tiene 2 tablas de dimensiones, depende de las relaciones entre las 3 tablas.

¿Podría compartir su .pbix archivo para la prueba?

Recuerde eliminar la información confidencial.

Saludos
Kelly

¿Respondí a su pregunta? ¡Marque mi respuesta como una solución!

Debe especificar columnas en lugar de tablas. Por ejemplo

'DBO DIMProduct'[ProductName] IN VALUES ( 'OutputServices'[ProductName] )
    || 'DBO DIMProduct'[ProductName] IN VALUES ( 'Realtime'[ProductName] )

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.