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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
jhen_1020
Regular Visitor

Help with If Statement

Hi, 

 

I am new to Power Bi and currently havving challenges in creating an IF Statement. 

 

Here's what I am trying to accomplish. 

 

Status column is in Table 1

Sales count, Price and Quantity is in Table 2

 

What I want is something like this: If Status = "OLD",Price/ Sales Count else Price/ Sales Count times Quantity. 

 

Appreciate any response. 

 

Thank You!

1 ACCEPTED SOLUTION
v-yulgu-msft
Employee
Employee

Hi @jhen_1020,

 

If [Status], [Sales count], [Price] and [Quantity] are all added into the same visual, please try this similar measure:

If Status =
IF (
    SELECTEDVALUE ( 'Table1'[Status] ) = "OLD",
    SELECTEDVALUE ( Table2[Price] ) / SELECTEDVALUE ( Table2[Sales Count] ),
    SELECTEDVALUE ( Table2[Price] ) / SELECTEDVALUE ( Table2[Sales Count] )
        * SELECTEDVALUE ( Table2[Quantity] )
)

Regards,

Yuliana Gu

 

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
v-yulgu-msft
Employee
Employee

Hi @jhen_1020,

 

If [Status], [Sales count], [Price] and [Quantity] are all added into the same visual, please try this similar measure:

If Status =
IF (
    SELECTEDVALUE ( 'Table1'[Status] ) = "OLD",
    SELECTEDVALUE ( Table2[Price] ) / SELECTEDVALUE ( Table2[Sales Count] ),
    SELECTEDVALUE ( Table2[Price] ) / SELECTEDVALUE ( Table2[Sales Count] )
        * SELECTEDVALUE ( Table2[Quantity] )
)

Regards,

Yuliana Gu

 

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Ashish_Mathur
Super User
Super User

Hi,

 

Is there a connecting column between the 2 datasets?  If yes, then which one is it?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

the two tables are connected by name. 

Hi,

 

Share the dataset and show the expected result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Phil_Seamark
Employee
Employee

HI @jhen_1020

 

Are you trying to add a calculated measure or column?  If you are trying to add a calculated column, which of the tables are you adding it to?


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Hi, I am trying to add a measure. 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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