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
DataUsurper
Helper II
Helper II

Reference a table's text field in VAR for T/F Return Calc

Hello All o/

 

Am attempting to create a SUMX measure when a particular table field is from a certain source. Below is where I'm currently at but am uncertain how to reference that field, or if this is the most efficient way to create this sumx measure.

 

BadRef.png

 

 

WROR.Item_Total = 
VAR TEAMSource = IF(tbl_Orders_LineItemDetails[SOURCE]="TEAMUK",TRUE,FALSE)
VAR TRUECALC = SUMX(tbl_Orders_LineItemDetails,(tbl_Orders_LineItemDetails[QTY]-tbl_Orders_LineItemDetails[QTYSUB])*tbl_Orders_LineItemDetails[Actual_Price.Disc])*1.5
VAR FALSECALC = SUMX(tbl_Orders_LineItemDetails,tbl_Orders_LineItemDetails[QTY]*tbl_Orders_LineItemDetails[Actual_Price.Disc])
RETURN IF(TEAMSource=TRUE,TRUECALC,FALSECALC)

 

 

Thanks for the help

1 ACCEPTED SOLUTION

WROR.Item_Total = 
VAR TEAMSource = IF(SELECTEDVALUE(tbl_Orders_LineItemDetails[SOURCE],"Neg")="TEAMUK",TRUE,FALSE)
VAR TRUECALC = SUMX(tbl_Orders_LineItemDetails,(tbl_Orders_LineItemDetails[ITEMTOTAL])*1.5)
VAR FALSECALC = SUMX(tbl_Orders_LineItemDetails,(tbl_Orders_LineItemDetails[ITEMTOTAL])*1)
RETURN IF(TEAMSource=TRUE,TRUECALC,FALSECALC)

 

That seems to have done it.

View solution in original post

5 REPLIES 5
parry2k
Super User
Super User

@DataUsurper it is not very clear what you are trying to achieve, post some sample data with exepcted output to provide the solution.

 

Read this post to get your answer quickly.

https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@DataUsurper thanks for sharing pbix but it doesn't help as I don;t know what you are trying to achieve. You need to provide explanation based on your dataset what you are looking to achieve.

 

Unfortunately I don't have any magic wand to provide the solution without knowing what you need help with 🙂



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

It's rather quite simple

This would be an easy calcualted column, much like in excel

IF(Source="A", Calc1,Calc2)

As in the image I provided, along with the code, when I insert the logic check for source it says it isn't relatable. Did you view the image or look at the code I provided?

WROR.Item_Total = 
VAR TEAMSource = IF(SELECTEDVALUE(tbl_Orders_LineItemDetails[SOURCE],"Neg")="TEAMUK",TRUE,FALSE)
VAR TRUECALC = SUMX(tbl_Orders_LineItemDetails,(tbl_Orders_LineItemDetails[ITEMTOTAL])*1.5)
VAR FALSECALC = SUMX(tbl_Orders_LineItemDetails,(tbl_Orders_LineItemDetails[ITEMTOTAL])*1)
RETURN IF(TEAMSource=TRUE,TRUECALC,FALSECALC)

 

That seems to have done it.

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.