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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

DAX

Hello need help with a formula. 

 

I am trying to create a dax formula based off the below data. 

 

The formula should say

if the Sum/Count of the load number in Jan is 

less than 3 = "75.00"

greater than or equal to 3 =  "100.00"

greater than or equal to 4 = "125.00"

greater than 6 = "225.00"

 

other wise Null.

 

So Jan should give me a sum of 4 Loads and a fee of 125.00

Feb would give me a sum of 2 loads and a fee of 75.00 etc. 

 

Screenshot 2021-10-11 155124 - IF  State.png

1 ACCEPTED SOLUTION

try:

Measure = 
VAR _Count=COUNTROWS('Table')
RETURN
SWITCH(TRUE(),
_Count > 9, 300,
_Count >= 6, 200,
_Count >= 3 ,100,
_Count = 2, 75,
50)




Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

7 REPLIES 7
ryan_mayu
Super User
Super User

@Anonymous 

pls try this

Measure = 
VAR _count=COUNTROWS('Table')
return SWITCH(TRUE(),_count<3,75,_count=3,100,_count=4,125,_count>6,225)

1.PNG





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

Proud to be a Super User!




Anonymous
Not applicable

Hello  this is perfect How could I add a between in the formula ? for volume that is between 3 to 5 would equal 300

 

@Anonymous 

this logic is in conflict with your first one which is equal to 4 = "125.00"

pls clarity the whole logics or you can try to modify the measure like below.

Measure = 
VAR _count=COUNTROWS('Table')
return SWITCH(TRUE(),_count<3,75,_count=3,100,_count<5,300,_count>6,225)

 





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

Proud to be a Super User!




Anonymous
Not applicable

So For instance here is a new logic.

if count is equal to 1 = 50 
 if count is equal to  2 = 75
if count is between 3 to 5 = 100
if count is between 6 to 8 = 200

if count is greater than 9 = 300 

how could I write out the between version.

try:

Measure = 
VAR _Count=COUNTROWS('Table')
RETURN
SWITCH(TRUE(),
_Count > 9, 300,
_Count >= 6, 200,
_Count >= 3 ,100,
_Count = 2, 75,
50)




Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






@ryan_mayu, I did have a solution that has now been deleted given the simplicity of yours 😂!!

Love your work mate!

If I have posted a response that resolves your question, please accept it as a solution to formally close the post.

Also, if you are as passionate about Power BI, DAX and data as I am, please feel free to reach out if you have any questions, queries, or if you simply want to connect and talk to another data geek!

Want to connect?www.linkedin.com/in/theoconias

Thank you





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

Proud to be a Super User!




Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.