Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowGet inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.
In my data, sales orders are recorded at the line level. At each sales order line there is a campaign code to identify various attributes. I can SUM the lines by campaign code without any trouble at all. What I have been asked to provide is the Sum of the orders in which ANY of the sales order lines contain the campaign code. In the sample data below, the campaign code RZZDTA exists in only orders 1 & 2. I would like the calculation to give me the SUM of orers 1& 2 not just the sum of the order lines. The Desired result is the column labeled AssociatedOrderSum below. Likewise the CUST code shows up in all orders and should be the SUM of all order lines. At the very bottom is the formula I have been working on with no luck. It is based on the closest thing I could find.
Thanks in advance.
SAMPLE DATA:
OrderNum | OrderLine | TotalLineValue | Campaign |
1 | 1 | $1,265.56 | CUST |
1 | 2 | $407.94 | CUST |
1 | 3 | $1,816.92 | CUST |
1 | 4 | $1,355.88 | CUST |
1 | 5 | $1,477.98 | CUST |
1 | 6 | $1,613.58 | CUST |
1 | 7 | $1,559.76 | CUST |
1 | 8 | $1,644.00 | CUST |
1 | 9 | $294.99 | CUST |
1 | 10 | $1,019.04 | CUST |
1 | 11 | $2,909.94 | CUST |
1 | 12 | $1,663.65 | CUST |
1 | 14 | $660.00 | CUST |
1 | 15 | $5.00 | RZZDTA |
2 | 1 | $15.21 | CUST |
2 | 2 | $0.00 | CUST |
2 | 3 | $98.76 | CUST |
2 | 4 | $1,055.12 | CUST |
2 | 5 | $32.01 | CUST |
2 | 6 | $0.89 | CUST |
2 | 7 | $7.88 | CUST |
2 | 8 | $597.99 | RZZDTA |
3 | 1 | $55.50 | CUST |
3 | 2 | $654.23 | CUST |
3 | 3 | $98.74 | CUST |
3 | 4 | $1,008.56 | CUST |
4 | 1 | $899.99 | PJ99 |
4 | 2 | $7.84 | PJ99 |
4 | 3 | $0.50 | CUST |
Desired Result:
Campaign | CampaignSum | AssociatedOrderSum |
CUST | $ 20,716.64 | $ 22,227.46 |
RZZDTA | $ 602.99 | $ 19,502.10 |
PJ99 | $ 907.83 | $ 908.33 |
DAX Attempt:
Campaign Orders all =
VAR EventVals_ = Values(MKGT_CAMP[Campaign ID])
VAR OrderList_ =
CALCULATETABLE(
VALUES(Orders[OrderNum]),
MKGT_EVENT[Campaign ID] = EventVals_)
Return
CALCULATE(sum(Orders[TotalLineValue]),filter(Orders,Orders[OrderNum] in OrderList_))
Solved! Go to Solution.
Hi, @bkwohls
Please check the below picture, measure, and the sample pbix file's link, whether it is what you are looking for.
Hi, My name is Jihwan Kim.
If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.
If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.
Hi, @bkwohls
Please check the below picture, measure, and the sample pbix file's link, whether it is what you are looking for.
Hi, My name is Jihwan Kim.
If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.
If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.
PERFECT thank you. I will try and learn from your DAX and see what I was doing wrong. I think I missed the ALL filters.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the February 2025 Power BI update to learn about new features.
User | Count |
---|---|
83 | |
77 | |
40 | |
40 | |
35 |