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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

100% Stacked Column (Add total column)

Hi all,

 

I've created a 100% stacked chart that is split across 3 clinics (i.e. Clinic as the Axis). I would like to have a 4th column that shows the overall split (i.e. one does not take into consideration the clinic). How can I go about achieving this?

 

Current visual:

EL1988_0-1626163165311.png

EL1988_1-1626163484359.png

 

Data table:

DayClinicTypeColor
1ADogBrown
1BDogBrown
1BDogBrown
2ADogWhite
2BDogWhite
2CCatGrey
3BCatGrey
3CCatGrey
4ACatBlack
4ACatBlack
4CCatBlack
4CCatBlack
4CCatBlack
4CCatBlack
4CCatBlack
4CCatBlack
4CCatBlack
4CCatBlack
4CCatBlack
4CCatBlack
4CCatBlack
4CCatBlack
4CCatBlack

 

1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @Anonymous ,

 

What you can do is to create a disconnected with the clinics and total:

 

Clinic + total = UNION(DISTINCT('Table'[Clinic]),ROW("Clinic","Total"))

 

Now add the following measure:

Percentage of type = 
IF (
    SELECTEDVALUE ( 'Clinic + total'[Clinic] ) = "Total",
    DIVIDE (
        COUNT ( 'Table'[Type] ),
        CALCULATE ( COUNT ( 'Table'[Type] ), ALL ( 'Table'[Type] ) )
    ),
    DIVIDE (
        CALCULATE (
            COUNT ( 'Table'[Type] ),
            FILTER (
                ALL ( 'Table'[Clinic] ),
                'Table'[Clinic] = SELECTEDVALUE ( 'Clinic + total'[Clinic] )
            )
        ),
        CALCULATE (
            COUNT ( 'Table'[Type] ),
            FILTER (
                ALL ( 'Table'[Clinic] ),
                'Table'[Clinic] = SELECTEDVALUE ( 'Clinic + total'[Clinic] )
            ),
            ALL ( 'Table'[Type] )
        )
    )
)

Use this measrue for your visualization

 

MFelix_0-1626165998816.png

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

1 REPLY 1
MFelix
Super User
Super User

Hi @Anonymous ,

 

What you can do is to create a disconnected with the clinics and total:

 

Clinic + total = UNION(DISTINCT('Table'[Clinic]),ROW("Clinic","Total"))

 

Now add the following measure:

Percentage of type = 
IF (
    SELECTEDVALUE ( 'Clinic + total'[Clinic] ) = "Total",
    DIVIDE (
        COUNT ( 'Table'[Type] ),
        CALCULATE ( COUNT ( 'Table'[Type] ), ALL ( 'Table'[Type] ) )
    ),
    DIVIDE (
        CALCULATE (
            COUNT ( 'Table'[Type] ),
            FILTER (
                ALL ( 'Table'[Clinic] ),
                'Table'[Clinic] = SELECTEDVALUE ( 'Clinic + total'[Clinic] )
            )
        ),
        CALCULATE (
            COUNT ( 'Table'[Type] ),
            FILTER (
                ALL ( 'Table'[Clinic] ),
                'Table'[Clinic] = SELECTEDVALUE ( 'Clinic + total'[Clinic] )
            ),
            ALL ( 'Table'[Type] )
        )
    )
)

Use this measrue for your visualization

 

MFelix_0-1626165998816.png

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.