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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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