- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If statement (greater than) different tables
Hi -
Been pounding my head against this for weeks.. hopefully someone can help. I'm trying to calculate whether or not we've placed PO's at or before the required lead time.
I have 3 tables:
Vendor
PurchaseOrderHeader
PurchaseOrderDetail
The StandardLeadTime column is in the Vendor Table
and the Lead Time on PO column is a calculated colum in the PurchaseOrderDetail table
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @HeShootsNScores ,
Model 1
Result1
Model2
Result2
Try to create a measure like this.
Measure 2 =
VAR x =
CALCULATE(
SUM(Vendor[Value]),
FILTER( Vendor, Vendor[ItemCode] = SELECTEDVALUE(Vendor[ItemCode]))
)
RETURN
IF(
SELECTEDVALUE(PurchaseOrderDetail[Value]) >= x,
"Yes", "No"
)
Or Create a calculated column like this.
Column 2 =
VAR x =
CALCULATE(
SUM(Vendor[Value]),
ALLEXCEPT(PurchaseOrderDetail, PurchaseOrderDetail[ItemCode])
)
RETURN
IF(
PurchaseOrderDetail[Value] >= x,
"yES", "nO"
)
Best regards,
Lionel Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @HeShootsNScores ,
Model 1
Result1
Model2
Result2
Try to create a measure like this.
Measure 2 =
VAR x =
CALCULATE(
SUM(Vendor[Value]),
FILTER( Vendor, Vendor[ItemCode] = SELECTEDVALUE(Vendor[ItemCode]))
)
RETURN
IF(
SELECTEDVALUE(PurchaseOrderDetail[Value]) >= x,
"Yes", "No"
)
Or Create a calculated column like this.
Column 2 =
VAR x =
CALCULATE(
SUM(Vendor[Value]),
ALLEXCEPT(PurchaseOrderDetail, PurchaseOrderDetail[ItemCode])
)
RETURN
IF(
PurchaseOrderDetail[Value] >= x,
"yES", "nO"
)
Best regards,
Lionel Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This worked! Your model 2 calculated column worked. Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@HeShootsNScores wrote:
The StandardLeadTime column is in the Vendor Table
Your relationship is going in the wrong direction to be able to use RELATED() against the vendor table. The way you have the relationships modelled is effectively saying that one purchase order line can be related to many different vendors. This does not sound correct to me.
If you edit this relationship and change the cardinality from many-to-one to one-to-many (or vis-versa) this will switch the From/To columns and the RELATED() function will then be able to function as you expect.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is it a 1:many relationship between Vendor and OrderDetail tables? Is itemcode the same data type on both sides of the relationship? If so, Related should work. If not, you'll need to change it to that or use RELATEDTABLE() and an aggregation.
Regards,
Pat
Did I answer your question? Mark my post as a solution! Kudos are also appreciated!
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
@mahoneypa HoosierBI on YouTube
Helpful resources
Join us at the Microsoft Fabric Community Conference
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Microsoft Fabric Community Conference 2025
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
Subject | Author | Posted | |
---|---|---|---|
05-07-2024 12:47 AM | |||
04-15-2024 11:09 AM | |||
11-21-2023 08:09 AM | |||
04-11-2020 12:04 PM | |||
11-07-2023 07:15 AM |
User | Count |
---|---|
113 | |
76 | |
55 | |
54 | |
43 |
User | Count |
---|---|
183 | |
120 | |
80 | |
67 | |
57 |