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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Mumiah
Helper I
Helper I

Create a bar chart from table where it's the result of a division of filtered counts

Hey all, hopefully you can help me, I'm trying to figure out this complex (at least for me) output, basically I have a table called GTSSD and for the sake of simplicity has columns _Ticket Number, OR, AR. I need to output in a bar chart a percentage result of the division of AR by OR I need to be able to add filters to both AR and OR but I'm trying to keep it simple for now to figure out the logic, I have a working formula if I would just need the Grand Total division but I need the measure  to contemplate where the division is A by A, B by B, C by C, D by D and exclude XX

Working formula

SAMPLE_FORMULA = 
DIVIDE
(
CALCULATE(COUNT('GTSSD'[_Ticket Number]), NOT('GTSSD'[OR] IN {"Other"}))
,
CALCULATE(COUNT('GTSSD Tickets'[_Ticket Number]), NOT('GTSSD Tickets'[AR] IN {"Other"}))
)


These are sample values and sample outcome 

AR ColumnCount
A9
B9
C15
D11
Grand Total44
  
OR ColumnCount
A10
B15
C20
D25
Grand Total70
  
SAMPLE expected Output Table%
A90%
B60%
C75%
D44%
Grand Total63%


Actual look I'm going for but not related to the sample data from above
Mumiah_0-1759966538032.png

 

Again any help is truly appreciated is I had a working measure when I had a direct connection to the database but as soon as I switched to Import data for some reason that broke it.

 

1 ACCEPTED SOLUTION

So I was able to accomplish my goal by creating a separate table called 'Table_2' that contains the possible AR and OR values (A,B,C,D,Other) under column [Letter] and referencing it in the measure below, then build a bar chart where the [Letter] is the X Axis and the Measure below is the Y axis. But again thanks a lot @Irwan for your assistance on this issue really appreciate it.

Measure = 
VAR AR_Tickets = 
    CALCULATE(
        COUNT('table'[_Ticket Number]),
        FILTER('table',
            
            'table'[OR] = SELECTEDVALUE('Table_2'[Letter])
        )
    )
VAR OR_Tickets = 
    CALCULATE(
        COUNT('table'[_Ticket Number]),
        FILTER('table',
            
            'table'[OR] = SELECTEDVALUE('Table_2'[Letter])
        )
    )
RETURN
IF(OR_Tickets = 0, BLANK(), DIVIDE(AR_Tickets, OR_Tickets))

 

View solution in original post

10 REPLIES 10
Ashish_Mathur
Super User
Super User

Hi,

Create a dimension tablw which has A,B,C,D.  Create a relationship (Many to One and Single) from the first column of both tables to the Dimension table.  To your visual, drag the column from the Dimesnion table.  Write these measures

AR count = countrows('ar table')

OR count = countrows('or table')

Measure = divide([ar count],[or count])

Hope this helps.

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Mumiah
Helper I
Helper I

So in this sample the table has 3 columns Column 1 is _Ticket Number, column 2 is  AR and column 3 is OR.

Below I've created also a sample data, what I showcased above was the count of values  for each  Column , but hopefully with the data below it'll make more sense, again I appreciate your assistance. 

Column1Column2Column3
_ticket NumberAROR
1AA
2AA
3AA
4AA
5AA
6AA
7AA
8AA
9AA
10BA
11BB
12BB
13BB
14BB
15BB
16BB
17BB
18BB
19CB
20CB
21CB
22CB
23CB
24CB
25CB
26CC
27CC
28CC
29CC
30CC
31CC
32CC
33CC
34DC
35DC
36DC
37DC
38DC
39DC
40DC
41DC
42DC
43DC
44DC
45XXC
46XXD
47XXD
48XXD
49XXD
50XXD
51XXD
52XXD
53XXD
54XXD
55XXD
56XXD
57XXD
58XXD
59XXD
60XXD
61XXD
62XXD
63XXD
64XXD
65XXD
66XXD
67XXD
68XXD
69XXD
70XXD
71XXXX
72XXXX
73XXXX
74XXXX
75XXXX




hello @Mumiah 

 

please check if this accomodate your need.

Irwan_3-1759976916551.png

 

1. unpivot your table

Irwan_0-1759976719806.png

2. create a new table consisted of your AR/OR value. You can use summarize to AR or OR column whichever has the most value, but i just inputed manually because only A,B,C,D.

Irwan_1-1759976819734.png

3. create a new measure with following DAX.

Sample_formula =
var _OR =
COUNTX(
    FILTER(
        'Table',
        'Table'[Attribute]="OR"&&
        ('Table'[Value]="A"||'Table'[Value]="B"||'Table'[Value]="C"||'Table'[Value]="D")
    ),
    'Table'[_ticket Number]
)
var _AR =
COUNTX(
    FILTER(
        'Table',
        'Table'[Attribute]="AR"&&
        ('Table'[Value]="A"||'Table'[Value]="B"||'Table'[Value]="C"||'Table'[Value]="D")
    ),
    'Table'[_ticket Number]
)
Return
DIVIDE(
    _AR,
    _OR
)
4. plot in table visual. Take ID from the previous ID table.
Irwan_2-1759976882246.png

 

 Hope this will help.
Thank you.

So the data I provided in my previous very long post is the raw data there's not attribute and value  columns and the _Ticket number are unique. Regardless of that discrepancy, I tried tweaking the formula you provided, created the ID table but seems still only accurately calculates the total percentage which I had no problem with, basically I need the output table to be the AR A divided by OR A , AR B by OR B, etc, hopefully this clarifies a bit what I'm struggling with

ticket NumberAROR
1AA
2AA
3AA
4AA
5AA
6AA
7AA
8AA
9AA
10BA
11BB
12BB
13BB
14BB
15BB
16BB
17BB
18BB
19CB
20CB
21CB
22CB
23CB
24CB
25CB
26CC
27CC
28CC
29CC
30CC
31CC
32CC
33CC
34DC
35DC
36DC
37DC
38DC
39DC
40DC
41DC
42DC
43DC
44DC
45XXC
46XXD
47XXD
48XXD
49XXD
50XXD
51XXD
52XXD
53XXD
54XXD
55XXD
56XXD
57XXD
58XXD
59XXD
60XXD
61XXD
62XXD
63XXD
64XXD
65XXD
66XXD
67XXD
68XXD
69XXD
70XXD
71XXXX
72XXXX
73XXXX
74XXXX
75XXXX




 

hello @Mumiah 

 

Irwan_0-1759986861312.png

attribute and value columns come from unpivot AR and OR column.

Irwan_1-1759986938198.png

 

Thank you.

Hey Irawn again thanks for all your help, while this works with the very basic sample data I provided I can't use it as an approachable method as my table roughly other 50 other columns  that depend the source table not being modified as it would affect all other charts within the dashboard, do you have any ideas on how I can achieve this without adding steps in the advanced editor?

So I was able to accomplish my goal by creating a separate table called 'Table_2' that contains the possible AR and OR values (A,B,C,D,Other) under column [Letter] and referencing it in the measure below, then build a bar chart where the [Letter] is the X Axis and the Measure below is the Y axis. But again thanks a lot @Irwan for your assistance on this issue really appreciate it.

Measure = 
VAR AR_Tickets = 
    CALCULATE(
        COUNT('table'[_Ticket Number]),
        FILTER('table',
            
            'table'[OR] = SELECTEDVALUE('Table_2'[Letter])
        )
    )
VAR OR_Tickets = 
    CALCULATE(
        COUNT('table'[_Ticket Number]),
        FILTER('table',
            
            'table'[OR] = SELECTEDVALUE('Table_2'[Letter])
        )
    )
RETURN
IF(OR_Tickets = 0, BLANK(), DIVIDE(AR_Tickets, OR_Tickets))

 

Irwan
Super User
Super User

hello @Mumiah 

 

i assumed the grand total coming from total option (not a row value).

Irwan_0-1759972276625.png

create a new measure with following DAX.

Sample_formula =
var _OR =
SUMX(
    'OR',
    'OR'[Count]
)
var _AR =
SUMX(
    VALUES('AR'),
    'AR'[Count]
)
Return
DIVIDE(
    _AR,
    _OR
)

 

dont forget to create a relationship between AR and OR table.

Irwan_1-1759972356349.png

 

Hope this will help.

Thank you.

Hey Irwan thanks for your response but there are not 2 tables 'AR' and 'OR' are just columns from the same GTSSD table.

hello @Mumiah 

 

then how to differentiate which one is AR or OR if they are coming from one table?

is there another column that define AR or OR?


Thank you.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors