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! Learn more

Reply
devinep5
Frequent Visitor

Count values in column greater than or equal to different values

Hi,

I've been using the code below to separate values in a column into the ranges below.

However, my graph is showing only the first true value, "1 & Above" and ignoring the rest of the data ranges.
 
How would I get a count for the numbers that fall into ea

OverallStanineRangeAbove =
SWITCH (
TRUE(),
PT_1819[Overall Stanine] >= 1, "1 & Above",
PT_1819[Overall Stanine] >= 2, "2 & Above",
PT_1819[Overall Stanine] >= 3, "3 & Above",
PT_1819[Overall Stanine] >= 4, "4 & Above",
PT_1819[Overall Stanine] >= 5 , "5 & Above",
PT_1819[Overall Stanine] >= 6 , "6 & Above",
PT_1819[Overall Stanine] >= 7, "7 & Above",
PT_1819[Overall Stanine] >= 8, "8 & Above",
PT_1819[Overall Stanine] >= 9, "9 & Above",
Blank())
1 ACCEPTED SOLUTION

Hi @devinep5 ,

I have created this simple table initially:

overall.png

Is this your expected result?

result.png

If so, create a [OverallStanineRangeAbove] calculated column as x-axis using the previous formula:

 

OverallStanineRangeAbove = 
SWITCH (
TRUE(),
PT_1819[Overall Stanine] >= 9, "9 & Above",
PT_1819[Overall Stanine] >= 8, "8 & Above",
PT_1819[Overall Stanine] >= 7, "7 & Above",
PT_1819[Overall Stanine] >= 6, "6 & Above",
PT_1819[Overall Stanine] >= 5, "5 & Above",
PT_1819[Overall Stanine] >= 4, "4 & Above",
PT_1819[Overall Stanine] >= 3, "3 & Above",
PT_1819[Overall Stanine] >= 2, "2 & Above",
PT_1819[Overall Stanine] >= 1, "1 & Above",
Blank()
)

 

Then create a [Percentage] calculated column as y-axis using this formula:

 

Column = 
VAR _count =
    COUNT ( PT_1819[Overall Stanine] )
VAR _C1 =
    COUNTX (
        FILTER ( 'PT_1819', 'PT_1819'[Overall Stanine] >= 1 ),
        [Overall Stanine]
    )
VAR _C2 =
    COUNTX (
        FILTER ( 'PT_1819', 'PT_1819'[Overall Stanine] >= 2 ),
        [Overall Stanine]
    )
VAR _C3 =
    COUNTX (
        FILTER ( 'PT_1819', 'PT_1819'[Overall Stanine] >= 3 ),
        [Overall Stanine]
    )
VAR _C4 =
    COUNTX (
        FILTER ( 'PT_1819', 'PT_1819'[Overall Stanine] >= 4 ),
        [Overall Stanine]
    )
VAR _C5 =
    COUNTX (
        FILTER ( 'PT_1819', 'PT_1819'[Overall Stanine] >= 5 ),
        [Overall Stanine]
    )
VAR _C6 =
    COUNTX (
        FILTER ( 'PT_1819', 'PT_1819'[Overall Stanine] >= 6 ),
        [Overall Stanine]
    )
VAR _C7 =
    COUNTX (
        FILTER ( 'PT_1819', 'PT_1819'[Overall Stanine] >= 7 ),
        [Overall Stanine]
    )
VAR _C8 =
    COUNTX (
        FILTER ( 'PT_1819', 'PT_1819'[Overall Stanine] >= 8 ),
        [Overall Stanine]
    )
VAR _C9 =
    COUNTX (
        FILTER ( 'PT_1819', 'PT_1819'[Overall Stanine] >= 9 ),
        [Overall Stanine]
    )
RETURN
    SWITCH (
        TRUE (),
        'PT_1819'[Overall Stanine] >= 9, _C9 / _count,
        'PT_1819'[Overall Stanine] >= 8, _C8 / _count,
        'PT_1819'[Overall Stanine] >= 7, _C7 / _count,
        'PT_1819'[Overall Stanine] >= 6, _C6 / _count,
        'PT_1819'[Overall Stanine] >= 5, _C5 / _count,
        'PT_1819'[Overall Stanine] >= 4, _C4 / _count,
        'PT_1819'[Overall Stanine] >= 3, _C3 / _count,
        'PT_1819'[Overall Stanine] >= 2, _C2 / _count,
        'PT_1819'[Overall Stanine] >= 1, _C1 / _count,
        BLANK ()
    )

 

It will get the above result in the column chart.

Attached my sample file that hopes to help you: Count values in column greater than or equal to different values.pbix

 

Best Regards,
Yingjie Li

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

4 REPLIES 4
amitchandak
Super User
Super User

@devinep5 , Change the order

OverallStanineRangeAbove =
SWITCH (
TRUE(),
PT_1819[Overall Stanine] >= 9, "9 & Above",
PT_1819[Overall Stanine] >= 8, "8 & Above",
PT_1819[Overall Stanine] >= 7, "7 & Above",
PT_1819[Overall Stanine] >= 6 , "6 & Above",
PT_1819[Overall Stanine] >= 5 , "5 & Above",
PT_1819[Overall Stanine] >= 4, "4 & Above",
PT_1819[Overall Stanine] >= 3, "3 & Above",
PT_1819[Overall Stanine] >= 2, "2 & Above",
PT_1819[Overall Stanine] >= 1, "1 & Above",
Blank())

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Apologies, I hadn't unfiltered the data before replying to you.
The bottom graph is what it looks like now. As you can see, "1 & above" should be 100% (because everyone has achieved at elast a 1 mark), biut the percentage as you can see in the screenshot below is showing only 1%.

devinep5_0-1594665075302.png

 

Hi @devinep5 ,

I have created this simple table initially:

overall.png

Is this your expected result?

result.png

If so, create a [OverallStanineRangeAbove] calculated column as x-axis using the previous formula:

 

OverallStanineRangeAbove = 
SWITCH (
TRUE(),
PT_1819[Overall Stanine] >= 9, "9 & Above",
PT_1819[Overall Stanine] >= 8, "8 & Above",
PT_1819[Overall Stanine] >= 7, "7 & Above",
PT_1819[Overall Stanine] >= 6, "6 & Above",
PT_1819[Overall Stanine] >= 5, "5 & Above",
PT_1819[Overall Stanine] >= 4, "4 & Above",
PT_1819[Overall Stanine] >= 3, "3 & Above",
PT_1819[Overall Stanine] >= 2, "2 & Above",
PT_1819[Overall Stanine] >= 1, "1 & Above",
Blank()
)

 

Then create a [Percentage] calculated column as y-axis using this formula:

 

Column = 
VAR _count =
    COUNT ( PT_1819[Overall Stanine] )
VAR _C1 =
    COUNTX (
        FILTER ( 'PT_1819', 'PT_1819'[Overall Stanine] >= 1 ),
        [Overall Stanine]
    )
VAR _C2 =
    COUNTX (
        FILTER ( 'PT_1819', 'PT_1819'[Overall Stanine] >= 2 ),
        [Overall Stanine]
    )
VAR _C3 =
    COUNTX (
        FILTER ( 'PT_1819', 'PT_1819'[Overall Stanine] >= 3 ),
        [Overall Stanine]
    )
VAR _C4 =
    COUNTX (
        FILTER ( 'PT_1819', 'PT_1819'[Overall Stanine] >= 4 ),
        [Overall Stanine]
    )
VAR _C5 =
    COUNTX (
        FILTER ( 'PT_1819', 'PT_1819'[Overall Stanine] >= 5 ),
        [Overall Stanine]
    )
VAR _C6 =
    COUNTX (
        FILTER ( 'PT_1819', 'PT_1819'[Overall Stanine] >= 6 ),
        [Overall Stanine]
    )
VAR _C7 =
    COUNTX (
        FILTER ( 'PT_1819', 'PT_1819'[Overall Stanine] >= 7 ),
        [Overall Stanine]
    )
VAR _C8 =
    COUNTX (
        FILTER ( 'PT_1819', 'PT_1819'[Overall Stanine] >= 8 ),
        [Overall Stanine]
    )
VAR _C9 =
    COUNTX (
        FILTER ( 'PT_1819', 'PT_1819'[Overall Stanine] >= 9 ),
        [Overall Stanine]
    )
RETURN
    SWITCH (
        TRUE (),
        'PT_1819'[Overall Stanine] >= 9, _C9 / _count,
        'PT_1819'[Overall Stanine] >= 8, _C8 / _count,
        'PT_1819'[Overall Stanine] >= 7, _C7 / _count,
        'PT_1819'[Overall Stanine] >= 6, _C6 / _count,
        'PT_1819'[Overall Stanine] >= 5, _C5 / _count,
        'PT_1819'[Overall Stanine] >= 4, _C4 / _count,
        'PT_1819'[Overall Stanine] >= 3, _C3 / _count,
        'PT_1819'[Overall Stanine] >= 2, _C2 / _count,
        'PT_1819'[Overall Stanine] >= 1, _C1 / _count,
        BLANK ()
    )

 

It will get the above result in the column chart.

Attached my sample file that hopes to help you: Count values in column greater than or equal to different values.pbix

 

Best Regards,
Yingjie Li

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

Thanks for the reply, however, it's still showing only one data range, "1 & above".

Essentially what I'm trying to do is have on the X-axis, total achieving "1 & above", "2 & above", etc.

 

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.