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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Syndicate_Admin
Administrator
Administrator

Quitar columna en función de la condición

Hola a todos, tengo múltiples columnas con mulitple producto. Me gustaría filtrar o preparar el informe cliente Vs productos no optados.

Por ejemplo: Tabla 1:
Customer_NumCustomer_NameUbicaciónManager_Name
CUST_001Juan CCosta afueraMathhew A
CUST_002Mathhew AIn situMathhew A
CUST_003Pablo PIn situMathhew A
CUST_004Tom RIn situMathhew A
CUST_005Darren CIn situMathhew A
CUST_006Pablo HCosta afueraMathhew A
CUST_007Johnathan RIn situJohnathan R
CUST_008Marc PCosta afueraJohnathan R
CUST_009Marca ACosta afueraJohnathan R
CUST_010Nisha PIn situJohnathan R
CUST_011Kumar KCosta afueraJohnathan R

Tabla 2:

Customer_NumCustomer_NameProducto1Producto2Producto3Producto4Producto5Producto6Producto7Producto8Producto9Producto10OptadoNoaplicableNo optó
CUST_001Juan CYYYYYYYYYY1000
CUST_002Mathhew ANYNYYYYYYY802
CUST_003Pablo PENYENYYYYYYY820
CUST_004Tom RYYYYNYYYYY901
CUST_005Darren CNYENYENYYYYY721
CUST_006Pablo HENYYYYYYYYY910
CUST_007Johnathan RYYNYYYYYYY901
CUST_008Marc PNYENYYYYYYY811
CUST_009Marca AENYYYNYYYYY811
CUST_010Nisha PYYYYENYYYYY910
CUST_011Kumar KNYYYYYYYYY901

Informe requerido:

Customer_NumCustomer_NameManager_NameProducto1Producto3Producto5No optó
CUST_004Tom R N1
CUST_005Darren C N 1
CUST_007Johnathan R N 1
CUST_008Marc P N 1
CUST_009Marca A N1
CUST_011Kumar K N 1
CUST_002Mathhew A NN 2

¿Podría alguien proporcionar un proceso paso a paso para crear el informe DE DETALLES ANTERIORES UTILIZANDO POWER Query y Power View? Muchas gracias

1 ACCEPTED SOLUTION
Syndicate_Admin
Administrator
Administrator

Hay @chratnaa5 ,

Primero seleccione el Customer_Num y Customer_Name, luego despivot otras columnas.

vkkfmsft_0-1632881196470.png

Si tiene un requisito para el orden entre columnas en la matriz, puede agregar esa columna personalizada para ordenar la columna Atributo.

= if [Attribute] = "Opted" then 11 else if [Attribute] = "NotApplicable" then 12 else if [Attribute] = "Not Opted" then 13 else Text.Select([Attribute], {"0".."9"})

vkkfmsft_1-1632881258069.png

vkkfmsft_3-1632881420513.png

A continuación, cree y utilice la siguiente medida.

Measure = 
CALCULATE (
    MAX ( 'Table 2'[Value] ),
    FILTER (
        'Table 2',
        'Table 2'[Value] = "N" 
            || ( 'Table 2'[Attribute] = "Not Opted" && MAX ( 'Table 2'[Value] ) <> "0" )
    )
)

vkkfmsft_2-1632881390359.png

Si el problema aún no se resuelve, proporcione información detallada sobre el error o el resultado esperado que espera. Hágamelo saber de inmediato, esperando su respuesta.

Saludos
Winniz

Si esta publicación ayuda, considere Aceptarla como la solución para ayudar a los otros miembros a encontrarla más rápidamente.

View solution in original post

8 REPLIES 8
Syndicate_Admin
Administrator
Administrator

Hay @chratnaa5 ,

Primero seleccione el Customer_Num y Customer_Name, luego despivot otras columnas.

vkkfmsft_0-1632881196470.png

Si tiene un requisito para el orden entre columnas en la matriz, puede agregar esa columna personalizada para ordenar la columna Atributo.

= if [Attribute] = "Opted" then 11 else if [Attribute] = "NotApplicable" then 12 else if [Attribute] = "Not Opted" then 13 else Text.Select([Attribute], {"0".."9"})

vkkfmsft_1-1632881258069.png

vkkfmsft_3-1632881420513.png

A continuación, cree y utilice la siguiente medida.

Measure = 
CALCULATE (
    MAX ( 'Table 2'[Value] ),
    FILTER (
        'Table 2',
        'Table 2'[Value] = "N" 
            || ( 'Table 2'[Attribute] = "Not Opted" && MAX ( 'Table 2'[Value] ) <> "0" )
    )
)

vkkfmsft_2-1632881390359.png

Si el problema aún no se resuelve, proporcione información detallada sobre el error o el resultado esperado que espera. Hágamelo saber de inmediato, esperando su respuesta.

Saludos
Winniz

Si esta publicación ayuda, considere Aceptarla como la solución para ayudar a los otros miembros a encontrarla más rápidamente.

La solución está funcionando bien. Muchas gracias.

Hola

Busque el archivo de Power BI adjunto. Mensaje de error que aparece:

Tipo de retroalimentación:
Fruncir el ceño (error)

Mensaje de error:
No se encontró ningún controlador para el tipo de mensaje 'Microsoft.Mashup.Evaluator.MessageBasedOutputStream+BinaryChunkMessage'.

Seguimiento de pila:
Microsoft.Mashup.Host.Document.SerializedException
en Microsoft.Mashup.Evaluator.MessageHandlers.Dispatch(canal IMessageChannel, mensaje de mensaje)
en Microsoft.Mashup.Evaluator.ChannelMessenger.ChannelMessageHandlers.TryDispatch(Canal IMessageChannel, Mensaje de mensaje)
en Microsoft.Mashup.Evaluator.MessageHandlers.Dispatch(canal IMessageChannel, mensaje de mensaje)
en Microsoft.Mashup.Evaluator.Interface.IMessageChannelExtensions.WaitFor[T](canal IMessageChannel)
en Microsoft.Mashup.Evaluator.RemoteDocumentEvaluator.RemoteEvaluation.TranslateCancelExceptions(Acción de acción)
en Microsoft.Mashup.Evaluator.RemoteDocumentEvaluator.RemoteEvaluation.IgnoreCancelExceptions(Acción de acción)
en Microsoft.Mashup.Evaluator.RemoteDocumentEvaluator.RemoteEvaluation.Finish()
en Microsoft.Mashup.Evaluator.Interface.IDataReaderSourceExtensions.<>c__DisplayClass1_0.<AfterDispose>b__0()
en Microsoft.Mashup.Evaluator.Interface.NotifyingDataReaderSource.Dispose()
en Microsoft.Mashup.Evaluator.Interface.EvaluationResultExtensions.Dispose[T](EvaluationResult2'1 result)
en Microsoft.Mashup.Evaluator.LimitedDocumentEvaluatorFactory.Evaluation'1.<>c__DisplayClass10_0.<Complete>b__0()
en Microsoft.Mashup.Evaluator.Interface.NotifyingDataReaderSource.Dispose()
en Microsoft.Mashup.Evaluator.DocumentEvaluator.<>c__DisplayClass7_1'1.<BeginGetResult>b__1()
en Microsoft.Mashup.Evaluator.Interface.NotifyingDataReaderSource.Dispose()
en Microsoft.Mashup.Evaluator.Interface.EvaluationResultExtensions.Dispose[T](EvaluationResult2'1 result)
en Microsoft.Mashup.Evaluator.LimitedDocumentEvaluatorFactory.Evaluation'1.<>c__DisplayClass10_0.<Complete>b__0()
en Microsoft.Mashup.Evaluator.Interface.NotifyingDataReaderSource.Dispose()
en Microsoft.Mashup.Evaluator.Interface.EvaluationResultExtensions.Dispose[T](EvaluationResult2'1 result)
en Microsoft.Mashup.OleDbProvider.DataHost.MashupEvaluator.<>c__DisplayClass4_1.<Evaluate>b__1()
en Microsoft.Mashup.Evaluator.Interface.NotifyingDataReaderSource.Dispose()
en Microsoft.Mashup.Engine.Interface.Tracing.TracingDataReaderSource.Dispose()
en Microsoft.Mashup.Evaluator.Interface.IDataReaderSourceExtensions.<>c__DisplayClass1_0.<AfterDispose>b__0()
en Microsoft.Mashup.Evaluator.Interface.NotifyingDataReaderSource.Dispose()
en Microsoft.Mashup.OleDbProvider.MashupCommandEvaluation.Dispose()
en Microsoft.Mashup.OleDbProvider.TracingMultipleResults.Dispose()

Mensaje de seguimiento de pila:
No se encontró ningún controlador para el tipo de mensaje 'Microsoft.Mashup.Evaluator.MessageBasedOutputStream+BinaryChunkMessage'.

Seguimiento de pila de invocación:
en Microsoft.Mashup.Host.Document.ExceptionExtensions.GetCurrentInvocationStackTrace()
en Microsoft.Mashup.Client.UI.Shared.StackTraceInfo.. ctor(String exceptionStackTrace, String invocationStackTrace, String exceptionMessage)
en Microsoft.PowerBI.Client.Windows.Telemetry.PowerBIUserFeedbackServices.GetStackTraceInfo(Exception e)
en Microsoft.PowerBI.Client.Windows.Telemetry.PowerBIUserFeedbackServices.ReportException(IWindowHandle activeWindow, IUIHost uiHost, FeedbackPackageInfo feedbackPackageInfo, Exception e, Boolean useGDICapture)
en Microsoft.Mashup.Client.UI.Shared.UnexpectedExceptionHandler.<>c__DisplayClass15_0.<HandleException>b__0()
en Microsoft.Mashup.Host.Document.SynchronizationContextExtensions.<>c__DisplayClass2_1.<SendAndMarshalExceptions>b__0(Object null)
en System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
en System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
en System.Delegate.DynamicInvokeImpl(Object[] args)
en System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry tme)
en System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(Object obj)
en System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
en System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
en System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
en System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry tme)
en System.Windows.Forms.Control.InvokeMarshaledCallbacks()
en System.Windows.Forms.Control.WndProc(Message& m)
en System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
en System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
en System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
en System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
en System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Motivo Int32, contexto ApplicationContext)
en System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Motivo Int32, contexto ApplicationContext)
en System.Windows.Forms.Form.ShowDialog(propietario de IWin32Window)
en Microsoft.Mashup.Client.UI.Windows.DialogWindowBase.ShowModal(IWindowHandle windowHandle)
en Microsoft.Mashup.Client.UI.Shared.WindowManager.ShowModal[T](cuadro de diálogo T, Func'1 showModalFunction)
en Microsoft.PowerBI.Client.Windows.FloatingDialog.KoLoadToReportDialog.TryShowDialog(Informe de informe, IExceptionHandler exceptionHandler, IPowerBIWindowService windowService, IQueryServices queryServices, IDesktopModelingHost modelingHost, LocalizedString title, LoadToModelContext loadToModelContext)
en Microsoft.PowerBI.Client.Windows.FloatingDialog.KoLoadToReportDialog.<>c__DisplayClass16_0.<TryShowDialogForQueries>b__0()
en Microsoft.PowerBI.Client.Windows.Report.<>c__DisplayClass60_0'1.<SynchronizeLooselyWithQueries>b__0()
en Microsoft.PowerBI.Client.Windows.Report.<SynchronizeLooselyWithQueriesAsync>d__61'1.MoveNext()
en System.Runtime.CompilerServices.AsyncTaskMethodBuilder'1.Start[TStateMachine](TStateMachine& stateMachine)
en Microsoft.PowerBI.Client.Windows.Report.SynchronizeLooselyWithQueriesAsync[T](Func'1 getTask)
en Microsoft.PowerBI.Client.Windows.Report.SynchronizeLooselyWithQueries[T](acción de Func'1)
en Microsoft.PowerBI.Client.Windows.Services.QueriesEditorWindowManager.ApplyQueryChanges(IEnumerable'1 queriesToLoad)
en Microsoft.Mashup.Host.Document.ExceptionHandlerExtensions.HandleExceptions(IExceptionHandler exceptionHandler, Acción de acción)
en System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
en System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
en System.Delegate.DynamicInvokeImpl(Object[] args)
en System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry tme)
en System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(Object obj)
en System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
en System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
en System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
en System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry tme)
en System.Windows.Forms.Control.InvokeMarshaledCallbacks()
en System.Windows.Forms.Control.WndProc(Message& m)
en System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
en System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
en System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
en System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
en System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Motivo Int32, contexto ApplicationContext)
en System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Motivo Int32, contexto ApplicationContext)
en System.Windows.Forms.Form.ShowDialog(propietario de IWin32Window)
en Microsoft.Mashup.Client.UI.Shared.WindowManager.ShowModal[T](cuadro de diálogo T, Func'1 showModalFunction)
en Microsoft.PowerBI.Client.Program.<>c__DisplayClass4_0.<Main>b__1()
en Microsoft.PowerBI.Client.Windows.IExceptionHandlerExtensions.<>c__DisplayClass3_0.<HandleExceptionsWithNestedTasks>b__0()
en Microsoft.Mashup.Host.Document.ExceptionHandlerExtensions.HandleExceptions(IExceptionHandler exceptionHandler, Acción de acción)
en Microsoft.PowerBI.Client.Program.Main(String[] args)


PowerBINonFatalError:
{"AppName":"PBIDesktop","AppVersion":"2.95.983.0","ModuleName":"","Component":"Microsoft.Mashup.Evaluator.MessageHandlers","Error":"Microsoft.Mashup.Host.Document.SerializedException - System.InvalidOperationException","MethodDef":"Dispatch","ErrorOffset":""}

Registros de seguimiento de instantáneas:
C:\Users\SadgunYashveer\AppData\Local\Microsoft\Power BI Desktop\FrownSnapShot4c44e12b-93e3-4f09-9d1d-129d17658e4a.zip

Modo predeterminado del modelo:
Importación

Versión del modelo:
PowerBI_V3

Registros de seguimiento de rendimiento:
C:\Users\SadgunYashveer\AppData\Local\Microsoft\Power BI Desktop\PerformanceTraces.zip

Funciones de vista previa habilitadas:
PBI_JsonTableInference
PBI_NewWebTableInference
PBI_ImportTextByExample
PBI_ExcelTableInference
PBI_rdlNativeVisual

Características de vista previa deshabilitadas:
PBI_shapeMapVisualEnabled
PBI_SpanishLinguisticsEnabled
PBI_qnaLiveConnect
PBI_azureMapVisual
PBI_dataPointLassoSelect
PBI_compositeModelsOverAS
PBI_dynamicParameters
PBI_enhancedTooltips
PBI_enableWebView2

Opciones de DirectQuery deshabilitadas:
TreatHanaAsRelationalSource

Nube:
GlobalCloud

PowerBINonFatalError_ErrorDescription:
System.InvalidOperationException

PowerBIUserFeedbackServices_IsReported:
Verdadero

Fórmulas:


sección Sección1;

Customer_Details compartido = let
Source = Excel.Workbook(File.Contents("C:\PowerBI\Test Data\Test_Data.xlsx"), null, true),
Customer_Details_Sheet = Source{[Item="Customer_Details",Kind="Sheet"]}[Data],
#"Changed Type" = Table.TransformColumnTypes(Customer_Details_Sheet,{{"Column1", type text}, {"Column2", type text}, {"Column3", type text}, {"Column4", type text}}),
#"Encabezados promocionados" = Table.PromoteHeaders(#"Changed Type", [PromoteAllScalars=true]),
#"Changed Type1" = Table.TransformColumnTypes(#"Encabezados promocionados",{{"Customer_Num", escriba texto}, {"Customer_Name", escriba texto}, {"Ubicación", escriba texto}, {"Manager_Name", escriba texto}})
en
#"Tipo1 cambiado";

  • Product_details compartido = dejar
    Source = Excel.Workbook(File.Contents("C:\PowerBI\Test Data\Test_Data.xlsx"), null, true),
    Product_details_Sheet = Source{[Item="Product_details",Kind="Sheet"]}[Data],
    #"Encabezados promocionados" = Table.PromoteHeaders(Product_details_Sheet, [PromoteAllScalars=true]),
    #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Customer_Num", type text}, {"Customer_Name", type text}, {"Product1", type text}, {"Product2", type text}, {"Product3", type text}, {"Product4", type text}, {"Product5", type text}, {"Product6", type text}, {"Product7", type text}, {"Product8", type text}, {"Product9", type text}, {"Product10", type text}, {"Total_PROD", Int64.Type}, {"NotApplicable", Int64.Type}, {"Not Opted", Int64.Type}}),
    #"Otras columnas no votadas" = Table.UnpivotOtherColumns(#"Changed Type", {"Customer_Num", "Customer_Name"}, "Attribute", "Value"),
    #"Added Custom" = Table.AddColumn(#"Unpivoted Other Columns", "Order", each if [Attribute] = "Opted" then 11 else if [Attribute] = "NotApplicable" then 12 else if [Attribute] = "Not Opted" then 13 else Text.Select([Attribute], {"0".." 9"}))
    en
    #"Personalizado añadido";

Hay @chratnaa5 ,

No pude encontrar el archivo de Power BI adjunto, ¿podría compartir su archivo PBIX nuevamente?

Saludos
Winniz

Lo siento, algún problema con mi perfil, no puedo adjuntar el archivo.

Syndicate_Admin
Administrator
Administrator

@aj1973 - Había dado datos de muestra. En el sistema en vivo tengo más de 60 productos únicos, quiero decir que los nombres de las columnas son diferentes. No pude encontrar resultados finales.

Sin embargo, muchas gracias por su tiempo.

Hay @chratnaa5 ,

¿Se ha resuelto su problema? Si el problema aún no se resuelve, proporcione información detallada sobre el error o el resultado esperado que espera. Hágamelo saber de inmediato, esperando su respuesta.

Saludos

Winniz

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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

Top Solution Authors