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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
jbrines
Helper II
Helper II

Create a chart that shows one Company against the rest

Hi Guys,

 

I have two columns Company and Created.

 

The Company one has multiple Comapny Names but also My company name.

 

I want to be able to show a chart with a count of My Comapny Name and count of the rest.

 

Would also like to base these number over Monthly counts.

 

Many thanks.

 

1 ACCEPTED SOLUTION
Bibiano_Geraldo
Super User
Super User

HI @jbrines ,
To achieve your goal of creating a chart that counts Clark Contracts as one bar and all other companies as another bar, and also bases these counts on a monthly basis, you can use the bellow DAX measures:

1- Create a Measure for "Clark Contracts" Count:

ClarkContractsCount = 
CALCULATE(
    COUNTROWS('Table'), 
    'Table'[Company] = "Clark Contracts"
)

 

2- Create a Measure for "Rest" Count:

RestCount = 
CALCULATE(
    COUNTROWS('Table'), 
    'Table'[Company] <> "Clark Contracts"
)

 

Once these measures are created, you can use them in a Clustered Bar Chart:

  • Drag the Month (or just use Year-Month if needed) to the Axis of the chart.
    Add the ClarkContractsCount and RestCount measures to the Values section.

Your output will look like this:

Bibiano_Geraldo_0-1738674039899.png

In this case is just showing one month because i used data provided by you in the comments sections.

 

Thank you

Is this post help you? Please consider to:

Accept as Solution!
Give a Kudo
Follow me on Linkedin

View solution in original post

12 REPLIES 12
Bibiano_Geraldo
Super User
Super User

HI @jbrines ,
To achieve your goal of creating a chart that counts Clark Contracts as one bar and all other companies as another bar, and also bases these counts on a monthly basis, you can use the bellow DAX measures:

1- Create a Measure for "Clark Contracts" Count:

ClarkContractsCount = 
CALCULATE(
    COUNTROWS('Table'), 
    'Table'[Company] = "Clark Contracts"
)

 

2- Create a Measure for "Rest" Count:

RestCount = 
CALCULATE(
    COUNTROWS('Table'), 
    'Table'[Company] <> "Clark Contracts"
)

 

Once these measures are created, you can use them in a Clustered Bar Chart:

  • Drag the Month (or just use Year-Month if needed) to the Axis of the chart.
    Add the ClarkContractsCount and RestCount measures to the Values section.

Your output will look like this:

Bibiano_Geraldo_0-1738674039899.png

In this case is just showing one month because i used data provided by you in the comments sections.

 

Thank you

Is this post help you? Please consider to:

Accept as Solution!
Give a Kudo
Follow me on Linkedin

Hi @Bibiano_Geraldo ,

 

How do I sort it do it is sorted by month newest to oldest?

 

Screenshot 2025-02-04 152347.jpg

Hi @Bibiano_Geraldo ,

 

Worked a treat many thanks.

 

J

parry2k
Super User
Super User

@jbrines I just stored my company in a measure to make the solution scalable, in case  my company name  changes. In this case, you just need to replace "Clark Contacts" with the new value.

 

To keep it simple, you can always replace the "my company" measure with the fixed value "Clark Contacts" or use the new measures that I provided. I always look for the solution which is easy to manage and scalable. Cheers!



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@jbrines change it to this:

 

Measure My Company = 
VAR __MyCompany = [Measure My Company]
RETURN
CALCULATE ( 
    [Measure Count],
    KEEPFILTERS ( Table[Company] = __MyCompany  )
)

Measure Rest = 
VAR __MyCompany = [Measure My Company]
RETURN
CALCULATE ( 
    [Measure Count],
    KEEPFILTERS ( Table[Company] <> __MyCompany )
)


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@jbrines create the following 4 measures to achieve the result, use "Measure My Company" and "My Rest" in the visual. You can always name the measures whatever you want.

 

Measure My Company = "Clark Contacts"

Measure Count = COUNTROWS ( Table )

Measure My Company = 
CALCULATE ( 
    [Measure Count],
    KEEPFILTERS ( Table[Company] = [Measure My Company] )
)

Measure Rest = 
CALCULATE ( 
    [Measure Count],
    KEEPFILTERS ( Table[Company] <> [Measure My Company] )
)

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Hi @parry2k ,

 

Getting the following on messre 3 and 4.

 

Screenshot 2025-02-04 122025.jpg

jbrines
Helper II
Helper II

Hi @parry2k ,

 

See sample below.

 

I am looking to show a chart that two bars (Clark Contracts and the Rest).

 

From the sample Clark Contacts will have a count of all Clark Contracts and the rest will have a count of everything except Clark Contracts.

 

I hope that makes sense?

 

Screenshot 2025-02-04 120145.jpg

 

Hi @jbrines, please use groups

Right-click on your column 'Company', group it, use the group in the chart

MattiaFratello_0-1738671128791.png

 

MattiaFratello_1-1738671139759.png

 

 

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

Hi @MattiaFratello ,

 

We have Companies being added all the time, would they be automatically added or would we have to do it manually?

 

J

Then why not to create a new column in the Power Query Editor, if the semantic model is not too big... 

MattiaFratello_0-1738676352830.png

 

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

 

parry2k
Super User
Super User

@jbrines how you determine which is "my company"? Can you share sample data with the expected output?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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