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
IF
Post Prodigy
Post Prodigy

category and sub-category in a table

Hi,

 

I have a table and I would like to add categories to the top.

 

school4th grade5th grade6th grade4th grade5th grade6th grade
A236356
B456358
C556667
D468467
E567458
F337588

 

I want to make it in this format:

 
 
 MaleFemale
school4th grade5th grade6th grade4th grade5th grade6th grade
A236356
B456358
C556667
D468467
E567458
F337588
 

Is it possible to do it with the power bi?

Thanks in advance

1 ACCEPTED SOLUTION
Icey
Community Support
Community Support

Hi @IF ,

 

So, P, R, O, P_, R_, O_ are calculated columns. Right?

If so, try this:

1. Enter data to create a "gendar" table.

gender.PNG

 

2. Create a measure like so:

Measure = 
VAR gender_ =
    SELECTEDVALUE ( gender[gender] )
VAR grade_ =
    SELECTEDVALUE ( gender[grade] )
VAR school_ = SELECTEDVALUE('Table (2)'[school])
RETURN
    SWITCH (
        gender_,
        "Male", SWITCH (
            grade_,
            "4th grade", SUM ( 'Table (2)'[4th grade] ),
            "5th grade", SUM ( 'Table (2)'[5th grade] ),
            "6th grade", SUM ( 'Table (2)'[6th grade] )
        ),
        "Female", SWITCH (
            grade_,
            "4th grade", SUM ( 'Table (2)'[4th grade.1] ),
            "5th grade", SUM ( 'Table (2)'[5th grade.1] ),
            "6th grade", SUM ( 'Table (2)'[6th grade.1] )
        )
    )

 

3. Create a Matrix visual.

re.PNG

BTW, .pbix file attached.

 

 

Best Regards,

Icey

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

7 REPLIES 7
Icey
Community Support
Community Support

Hi @IF ,

 

Is this problem solved?


If it is solved, please always accept the replies making sense as solution to your question so that people who may have the same question can get the solution directly.


If not, please let me know.

 


Best Regards,
Icey

Hi @IF ,

 

that is a matrix.

Check this out.

https://docs.microsoft.com/en-us/power-bi/visuals/desktop-matrix-visual

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast


Hi,

 

Thanks for the answer. However the situtation is little more complicated.

I don't have "male" and "female" information in my table. Besides, I display the data by using the logic:

A+B=4th grade

A+C=5th grade

A+D=6th grade

H+E=4th grade_

H+F=5th grade_

H+G=6th grade_

So I have only columns A,B,C,D,E,F,G,H. I want to display each three in a main category. A+B,A+C,A+D will be under male and H+E,H+F, and H+G will be under the female category.

I hope it is possible to do it.

All the best, 

Icey
Community Support
Community Support

Hi @IF ,

 

Can you provide some sample data with the same structure as your data table?

 

 

Best Regards,

Icey

IF
Post Prodigy
Post Prodigy

Hi,

Hi,

I wanted to keep  it simple, but the exact table is:

XXYYABCDEFGIJKLMNA2B2C2D2PROP_R_O_
353532M23467554678974684221114684
353533M4225255244788444514912445
353542M23467554678974684221114684
353547M4225265244788444515912445
353551M23467554678974984221114984
353552M4225255244788464514912645
353562M23467554678978684221114684
353565M4225255244788444514912445
353603M23469554678974984241114984
353771M4229285246788444621914446
353774M23467594678974684221514684
353777M42252582447864445141210445
353801M23467554678974688221114688
353805M4225255244798464514912645
353873M23967556678974984241114984
353877M4225255244788948814912488
353882M23667554698974984221116984

 

P is D+E+F+I       R IS G+J     O IS K+N   P_ IS B2   R_ is C2   O_ is D2

 

I want to group P, R and O as Group1. Similarly I want to group P_, R_ and O_ as Group2. This is going to display my table, which is possible to add a row in excel and type it after merging 3 columns. Is it possible to group them?

 

Regards

 

 

 

 

Icey
Community Support
Community Support

Hi @IF ,

 

So, P, R, O, P_, R_, O_ are calculated columns. Right?

If so, try this:

1. Enter data to create a "gendar" table.

gender.PNG

 

2. Create a measure like so:

Measure = 
VAR gender_ =
    SELECTEDVALUE ( gender[gender] )
VAR grade_ =
    SELECTEDVALUE ( gender[grade] )
VAR school_ = SELECTEDVALUE('Table (2)'[school])
RETURN
    SWITCH (
        gender_,
        "Male", SWITCH (
            grade_,
            "4th grade", SUM ( 'Table (2)'[4th grade] ),
            "5th grade", SUM ( 'Table (2)'[5th grade] ),
            "6th grade", SUM ( 'Table (2)'[6th grade] )
        ),
        "Female", SWITCH (
            grade_,
            "4th grade", SUM ( 'Table (2)'[4th grade.1] ),
            "5th grade", SUM ( 'Table (2)'[5th grade.1] ),
            "6th grade", SUM ( 'Table (2)'[6th grade.1] )
        )
    )

 

3. Create a Matrix visual.

re.PNG

BTW, .pbix file attached.

 

 

Best Regards,

Icey

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

IF
Post Prodigy
Post Prodigy

Hi,

I could not open the pbix file. It says: Something went wrong  ExecuteXmla failed with result.

BR

Feedback Type:
Frown (Error)

Error Message:
ExecuteXmla failed with result

Stack Trace:
at Microsoft.PowerBI.Client.Windows.AnalysisServices.AnalysisServicesService.ExecuteXmla(String xmla)
at Microsoft.PowerBI.Client.Windows.AnalysisServices.AnalysisServicesService.<>c__DisplayClass41_0.<ImageLoadDatabaseFromPbix>b__0()
at Microsoft.PowerBI.Client.Windows.AnalysisServices.AnalysisServicesService.OnErrorClarify(Action action, String clarification)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.PowerBI.Client.Windows.IExceptionHandlerExtensions.<>c__DisplayClass3_0.<HandleExceptionsWithNestedTasks>b__0()
at Microsoft.Mashup.Host.Document.ExceptionHandlerExtensions.HandleExceptions(IExceptionHandler exceptionHandler, Action action)

Stack Trace Message:
ExecuteXmla failed with result

Invocation Stack Trace:
at Microsoft.Mashup.Host.Document.ExceptionExtensions.GetCurrentInvocationStackTrace()
at Microsoft.Mashup.Client.UI.Shared.StackTraceInfo..ctor(String exceptionStackTrace, String invocationStackTrace, String exceptionMessage)
at Microsoft.PowerBI.Client.Windows.Telemetry.PowerBIUserFeedbackServices.GetStackTraceInfo(Exception e)
at Microsoft.PowerBI.Client.Windows.Telemetry.PowerBIUserFeedbackServices.ReportException(IWindowHandle activeWindow, IUIHost uiHost, FeedbackPackageInfo feedbackPackageInfo, Exception e, Boolean useGDICapture)
at Microsoft.Mashup.Client.UI.Shared.UnexpectedExceptionHandler.<>c__DisplayClass14_0.<HandleException>b__0()
at Microsoft.Mashup.Client.UI.Shared.UnexpectedExceptionHandler.HandleException(Exception e)
at Microsoft.Mashup.Host.Document.ExceptionHandlerExtensions.HandleExceptions(IExceptionHandler exceptionHandler, Action action)
at Microsoft.PowerBI.Client.Program.Main(String[] args)


PowerBINonFatalError:
{"AppName":"PBIDesktop","AppVersion":"2.82.5858.961","ModuleName":"Microsoft.PowerBI.Client.Windows.dll","Component":"Microsoft.PowerBI.Client.Windows.AnalysisServices.AnalysisServicesService","Error":"Microsoft.PowerBI.Client.Windows.AnalysisServices.XmlaExecutionException","MethodDef":"ExecuteXmla","ErrorOffset":"112"}

InnerException0.Stack Trace Message:
COM error: Microsoft.MashupEngine, A module named 'BIConnector' hasn't been loaded..


InnerException0.Stack Trace:


InnerException0.Invocation Stack Trace:
at Microsoft.Mashup.Host.Document.ExceptionExtensions.GetCurrentInvocationStackTrace()
at Microsoft.Mashup.Client.UI.Shared.FeedbackErrorInfo.GetFeedbackValuesFromException(Exception e, String prefix)
at Microsoft.Mashup.Client.UI.Shared.FeedbackErrorInfo.GetFeedbackValuesFromInnerExceptions(Exception e, Int32 depth)
at Microsoft.Mashup.Client.UI.Shared.FeedbackErrorInfo.CreateAdditionalErrorInfo(Exception e)
at Microsoft.Mashup.Client.UI.Shared.FeedbackErrorInfo..ctor(String message, Exception exception, Nullable`1 stackTraceInfo, String messageDetail)
at Microsoft.PowerBI.Client.Windows.Telemetry.PowerBIUserFeedbackServices.ReportException(IWindowHandle activeWindow, IUIHost uiHost, FeedbackPackageInfo feedbackPackageInfo, Exception e, Boolean useGDICapture)
at Microsoft.Mashup.Client.UI.Shared.UnexpectedExceptionHandler.<>c__DisplayClass14_0.<HandleException>b__0()
at Microsoft.Mashup.Client.UI.Shared.UnexpectedExceptionHandler.HandleException(Exception e)
at Microsoft.Mashup.Host.Document.ExceptionHandlerExtensions.HandleExceptions(IExceptionHandler exceptionHandler, Action action)
at Microsoft.PowerBI.Client.Program.Main(String[] args)

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.