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
Anonymous
Not applicable

Writing a measure based off of parameters (should be simple)

Hello, I have some data represented below

PBI4.png

 

I am looking to write a measure that returns a number (1-5 from the test column) based on the rules seen in the # Customers column. I want the number to appear on a card when one of the locations are selected. Thanks!

1 ACCEPTED SOLUTION
v-xiaotang
Community Support
Community Support

Hi @Anonymous 

try this

-

1. split column

vxiaotang_0-1629191310279.png

vxiaotang_1-1629191365986.png

2. create the measure

Tests Required = 
var _customers=SELECTEDVALUE(Location[Customers])
return
CALCULATE(MIN('Table'[# Tests Required]),FILTER('Table','Table'[Start]<=_customers&&'Table'[End]>=_customers))

result

vxiaotang_2-1629191673475.png

vxiaotang_3-1629191737283.png

 

 

Best Regards,

Community Support Team _Tang

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

View solution in original post

5 REPLIES 5
v-xiaotang
Community Support
Community Support

Hi @Anonymous 

Have you solved this problem? If yes, could you kindly accept the answer helpful as the solution (or kindly share your solution ). so the others can find it more quickly.
really appreciate!
Any question, please let me know. Looking forward to receiving your reply.


Best Regards,
Community Support Team _Tang

v-xiaotang
Community Support
Community Support

Hi @Anonymous 

try this

-

1. split column

vxiaotang_0-1629191310279.png

vxiaotang_1-1629191365986.png

2. create the measure

Tests Required = 
var _customers=SELECTEDVALUE(Location[Customers])
return
CALCULATE(MIN('Table'[# Tests Required]),FILTER('Table','Table'[Start]<=_customers&&'Table'[End]>=_customers))

result

vxiaotang_2-1629191673475.png

vxiaotang_3-1629191737283.png

 

 

Best Regards,

Community Support Team _Tang

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

Greg_Deckler
Community Champion
Community Champion

@Anonymous Split your column in your first table into two columns using "-" as your delimiter. Then the issue is trivial.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

This isn't how my data looks in my report. It's actually noot even included, I was hoping to just manually type in the numbers in the measure. Should I add a table and do it that way?

 

@Anonymous You could, or if you want it in a measure hard coded you can do this:

Tests Required Measure = 
  VAR __Customers = SUM('Table'[Customers])
RETURN
  SWITCH(TRUE(),
    __Customers > 0 && __Customers < 201,1,
    __Customers > 200 && __Customers < 501,1,
    __Customers > 500 && __Customers < 1001,1,
    __Customers > 1000 && __Customers < 2001,1,
    __Customers > 2000 && __Customers < 2501,1,
  )


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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