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
ABLRP
Regular Visitor

IF statement not working properly

Hello,

 

I am trying to do an easy if and such as below.

ABLRP_1-1646147096733.png

 

Then I want to count how many 1, 2 and 3 I have, and this is not working. It only shows 3.

ABLRP_2-1646147167930.png

Firts I could not use category=Cons because I am using direct query so I created a category code (Cons is category code 3).

 

Cost ABC2 =
if(
'MEASURES CONS'[Most Recent Price] >= 1000 && 'MEASURES ABC'[Category Code]=3, 1,
if(
'MEASURES CONS'[Most Recent Price] >= 250 && 'MEASURES CONS'[Most Recent Price] < 1000 && 'MEASURES ABC'[Category Code]=3, 2,
if(
'MEASURES CONS'[Most Recent Price] <= 250 && 'MEASURES ABC'[Category Code]=3, 3
)))
 
Am I doing something wrong?
1 ACCEPTED SOLUTION
JaromBIDEVatDK
Helper II
Helper II

Hi there,

A simple solution would be to use your measure you created but do it as a calculated column instead of a measure. You would set the column as the legend/column 1 and then column 2 of the table you would use the same column except set the column operation = count. 

 

Hope that helps. 

View solution in original post

4 REPLIES 4
ABLRP
Regular Visitor

Exactly, I am using a flag using the most recent date. I will try your suggestion 🙂 thank you

ABLRP
Regular Visitor

Hi Jarom,

 

Thank you for the help. The problem is that I have a table with all orders and I only want to categorize (1,2,3) according the most recent price. In this case I would be evaluating the same PN on different prices...

Is the current price it's own column so for every Row of a PN the current price is shown? Or are you using a date or some flag to identify which record is the current price? If the latter then you can do as I mentioned before and just add a filter to the visual for "current"  eq 1

JaromBIDEVatDK
Helper II
Helper II

Hi there,

A simple solution would be to use your measure you created but do it as a calculated column instead of a measure. You would set the column as the legend/column 1 and then column 2 of the table you would use the same column except set the column operation = count. 

 

Hope that helps. 

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