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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
Anonymous
Not applicable

Need some help on writing a measure to count numbers of bars.

Hi I am still new to DAX and I feel like it should be an easy DAX to write but I tried and couldn't figure it out.
I have a chart below, I want to have a measure that counts the number of bars that is below the target, these two green bars, in this case, it should retunrs "2" as the result. 

Thanks!!

bwang2_0-1717093805428.png

 

1 ACCEPTED SOLUTION
gmsamborn
Super User
Super User

Hi @Anonymous 

 

I'm not sure where you got your target so I hard coded it to be 8.

 

These measures should help.

Target = 8

Shifts = SUM( 'Table'[# of Shifts] )

Below = 
    COUNTROWS(
        FILTER(
            'Table',
            [Shifts] <= [Target]
        )
    )

 

Let me know if you have any questions.

 

bwang2.pbix

 



Proud to be a Super User!

daxformatter.com makes life EASIER!

View solution in original post

1 REPLY 1
gmsamborn
Super User
Super User

Hi @Anonymous 

 

I'm not sure where you got your target so I hard coded it to be 8.

 

These measures should help.

Target = 8

Shifts = SUM( 'Table'[# of Shifts] )

Below = 
    COUNTROWS(
        FILTER(
            'Table',
            [Shifts] <= [Target]
        )
    )

 

Let me know if you have any questions.

 

bwang2.pbix

 



Proud to be a Super User!

daxformatter.com makes life EASIER!

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 FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors
Top Kudoed Authors