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.
My company is currently using two completely seperate systmes to track sales in US vs sales for the rest of the world. Additionally we have two different types of sales, OP and UO orders. I am trying to create a cumulative sum that takes the data from both tables by day and does a grand total sum.
Here is what I have written so far. AR is one table and SO is a seperate table. They are both joined to a "Bookings Goal" Table by their dates. The HistDetailAll Table is joined by the Order Date and the TransDetailAll Table is joined by the TransDate.
Ive used this exact formula in other instances and gotten the results I was expecting. Im imagining this has to do with the fact that I am trying to pull from two different tables to get this result.
Any thoughts on what Im doing wrong here? Im hiting a wall.
Solved! Go to Solution.
Hi @ahoggatt42 ,
1. Create a calculation table and obtain data that meets the conditions.
Table =
UNION(SELECTCOLUMNS(
FILTER('AR Data','AR Data'[Order Type] = "UO"),
"MyDate",'AR Data'[Order Date],
"MyYear",'AR Data'[Order Year],
"MyMonth",'AR Data'[Order Month],
"MyPrice",'AR Data'[Sum of True Price]),
SELECTCOLUMNS(
FILTER('SO Data','SO Data'[Order Type] = "UO"),
"MyDate",'SO Data'[Trans Date],
"MyYear",'SO Data'[Trans Year],
"MyMonth",'SO Data'[Trans Month],
"MyPrice",'SO Data'[Sum of True Price]))
2. Create measure.
Measure =
CALCULATE(SUM('Table'[MyPrice]),FILTER(ALL('Table'), 'Table'[MyYear] = MAX('Table'[MyYear]) && 'Table'[MyMonth] = MAX('Table' [MyMonth]) &&'Table'[MyDate] <= MAX('Table'[MyDate])))
If your Current Period does not refer to this, please clarify in a follow-up reply.
Best Regards,
Clara Gong
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @ahoggatt42 ,
1. Create a calculation table and obtain data that meets the conditions.
Table =
UNION(SELECTCOLUMNS(
FILTER('AR Data','AR Data'[Order Type] = "UO"),
"MyDate",'AR Data'[Order Date],
"MyYear",'AR Data'[Order Year],
"MyMonth",'AR Data'[Order Month],
"MyPrice",'AR Data'[Sum of True Price]),
SELECTCOLUMNS(
FILTER('SO Data','SO Data'[Order Type] = "UO"),
"MyDate",'SO Data'[Trans Date],
"MyYear",'SO Data'[Trans Year],
"MyMonth",'SO Data'[Trans Month],
"MyPrice",'SO Data'[Sum of True Price]))
2. Create measure.
Measure =
CALCULATE(SUM('Table'[MyPrice]),FILTER(ALL('Table'), 'Table'[MyYear] = MAX('Table'[MyYear]) && 'Table'[MyMonth] = MAX('Table' [MyMonth]) &&'Table'[MyDate] <= MAX('Table'[MyDate])))
If your Current Period does not refer to this, please clarify in a follow-up reply.
Best Regards,
Clara Gong
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
I also created a calendar table (Bookings Goal)
I joined all three tables based on their dates
And using the same measure I used before:
Intl Cumulative UO Bookings (Month) =
var AR =
CALCULATE(
SUM('AR Data'[Sum of True Price]),
FILTER(
ALL('AR Data'),
'AR Data'[Order Date]<= MAX( 'AR Data'[Order Date]) &&
'AR Data'[Order Month] = MAX('AR Data'[Order Month])&&
'AR Data'[Order Year] = MAX('AR Data'[Order Year])&&
'AR Data'[Order Type] = "UO"
))
var SO =
CALCULATE(
SUM('SO Data'[Sum of True Price]),
FILTER(
ALL('SO Data'),
'SO Data'[Trans Date] <= MAX( 'SO Data'[Trans Date]) &&
'SO Data'[Trans Month] = MAX('SO Data'[Trans Month])&&
'SO Data'[Trans Year] = MAX('SO Data'[Trans Year])&&
'SO Data'[Order Type] = "UO"
))
Return
SO+AR
I get this result:
I am expecting that each column is a running sum by date.
I have this working for just one location now without any issues using the same code just without adding another site to it:
Intl Cumulative UO Revenue (Month) =
CALCULATE(
SUM(HistDetailAll[True Price]),
FILTER(
ALL(HistDetailAll),
HistDetailAll[actshipdate]<= MAX( HistDetailAll[actshipdate]) &&
HistDetailAll[Actual Month] = MAX(HistDetailAll[Actual Month])&&
HistDetailAll[Actual Year] = MAX(HistDetailAll[Actual Year]) &&
HistDetailAll[Order Type] = "UO"
))
And Here is the AR Data:
transid | partid | Order Date | Order Month | Order Year | Sum of True Price | Order Type |
00010993 | 29 | 3/4/2024 0:00 | 3 | 2024 | $68 | OP |
00010996 | 1 | 3/5/2024 0:00 | 3 | 2024 | $665 | OP |
00010998 | 51 | 3/5/2024 0:00 | 3 | 2024 | $98 | OP |
00010998 | 53 | 3/5/2024 0:00 | 3 | 2024 | $2,118 | OP |
00010999 | 30 | 3/6/2024 0:00 | 3 | 2024 | $68 | OP |
00010999 | 33 | 3/6/2024 0:00 | 3 | 2024 | $14,265 | OP |
00010999 | 2 | 3/6/2024 0:00 | 3 | 2024 | $568 | OP |
00010999 | 37 | 3/6/2024 0:00 | 3 | 2024 | $85 | OP |
00010999 | 10 | 3/6/2024 0:00 | 3 | 2024 | $478 | OP |
00010999 | 52 | 3/6/2024 0:00 | 3 | 2024 | $34 | OP |
00001282 | 63 | 3/6/2024 0:00 | 3 | 2024 | $26 | OP |
00010999 | 64 | 3/6/2024 0:00 | 3 | 2024 | $12 | OP |
00001282 | 66 | 3/6/2024 0:00 | 3 | 2024 | $105 | OP |
00010999 | 17 | 3/6/2024 0:00 | 3 | 2024 | $78 | OP |
00010999 | 71 | 3/6/2024 0:00 | 3 | 2024 | $2,888 | OP |
00011002 | 3 | 3/7/2024 0:00 | 3 | 2024 | $6,088 | OP |
00011002 | 39 | 3/7/2024 0:00 | 3 | 2024 | $554 | OP |
00011002 | 40 | 3/7/2024 0:00 | 3 | 2024 | $223 | OP |
00011002 | 41 | 3/7/2024 0:00 | 3 | 2024 | $602 | OP |
00011002 | 42 | 3/7/2024 0:00 | 3 | 2024 | $101 | OP |
00011002 | 43 | 3/7/2024 0:00 | 3 | 2024 | $453 | OP |
00011002 | 44 | 3/7/2024 0:00 | 3 | 2024 | $640 | OP |
00011002 | 45 | 3/7/2024 0:00 | 3 | 2024 | $101 | OP |
00011002 | 49 | 3/7/2024 0:00 | 3 | 2024 | $109 | OP |
00011002 | 54 | 3/7/2024 0:00 | 3 | 2024 | $25 | OP |
00011002 | 56 | 3/7/2024 0:00 | 3 | 2024 | $97 | OP |
00011002 | 57 | 3/7/2024 0:00 | 3 | 2024 | $11 | OP |
00011002 | 58 | 3/7/2024 0:00 | 3 | 2024 | $24 | OP |
00011002 | 62 | 3/7/2024 0:00 | 3 | 2024 | $19 | OP |
00011002 | 68 | 3/7/2024 0:00 | 3 | 2024 | $703 | OP |
00011002 | 69 | 3/7/2024 0:00 | 3 | 2024 | $11 | OP |
00011002 | 70 | 3/7/2024 0:00 | 3 | 2024 | $17 | OP |
00011001 | 22 | 3/7/2024 0:00 | 3 | 2024 | $13,019 | OP |
00011002 | 72 | 3/7/2024 0:00 | 3 | 2024 | $6,108 | OP |
00011004 | 34 | 3/11/2024 0:00 | 3 | 2024 | $43 | OP |
00011004 | 36 | 3/11/2024 0:00 | 3 | 2024 | $94 | OP |
00011008 | 32 | 3/12/2024 0:00 | 3 | 2024 | $665 | OP |
00011009 | 67 | 3/12/2024 0:00 | 3 | 2024 | $831 | OP |
00011015 | 29 | 3/15/2024 0:00 | 3 | 2024 | $68 | OP |
00011015 | 37 | 3/15/2024 0:00 | 3 | 2024 | $227 | OP |
00011015 | 46 | 3/15/2024 0:00 | 3 | 2024 | $603 | OP |
00011015 | 59 | 3/15/2024 0:00 | 3 | 2024 | $25 | OP |
00011015 | 60 | 3/15/2024 0:00 | 3 | 2024 | $73 | OP |
00011015 | 61 | 3/15/2024 0:00 | 3 | 2024 | $85 | OP |
00011015 | 22 | 3/15/2024 0:00 | 3 | 2024 | $343 | OP |
00011021 | 10 | 3/19/2024 0:00 | 3 | 2024 | $50 | OP |
00011021 | 48 | 3/19/2024 0:00 | 3 | 2024 | $112 | OP |
00011024 | 29 | 3/20/2024 0:00 | 3 | 2024 | $68 | OP |
00011024 | 2 | 3/20/2024 0:00 | 3 | 2024 | $57 | OP |
00011024 | 35 | 3/20/2024 0:00 | 3 | 2024 | $533 | OP |
00011024 | 50 | 3/20/2024 0:00 | 3 | 2024 | $3,267 | OP |
00011024 | 53 | 3/20/2024 0:00 | 3 | 2024 | $1,059 | OP |
00011024 | 65 | 3/20/2024 0:00 | 3 | 2024 | $6,460 | OP |
00011024 | 20 | 3/20/2024 0:00 | 3 | 2024 | $39 | OP |
00011036 | 31 | 3/22/2024 0:00 | 3 | 2024 | $919 | OP |
00011036 | 55 | 3/22/2024 0:00 | 3 | 2024 | $813 | OP |
00001044 | 24 | 3/26/2024 0:00 | 3 | 2024 | $274,560 | UO |
00011043 | 38 | 3/27/2024 0:00 | 3 | 2024 | $516 | OP |
00011043 | 47 | 3/27/2024 0:00 | 3 | 2024 | $209 | OP |
00011049 | 1 | 3/28/2024 0:00 | 3 | 2024 | $998 | OP |
Just to go one step further here is a sample of the data I am using.
This is the SO Table:
TransID | ItemId | Trans Date | Trans Month | Trans Year | Sum of True Price | Order Type |
00001041 | 27 | 3/1/2024 0:00 | 3 | 2024 | $351,574 | UO |
00001281 | 28 | 3/1/2024 0:00 | 3 | 2024 | $78,339 | UO |
00010995 | 3 | 3/4/2024 0:00 | 3 | 2024 | $43,800 | OP |
00010995 | 7 | 3/4/2024 0:00 | 3 | 2024 | $1,692 | OP |
00010995 | 9 | 3/4/2024 0:00 | 3 | 2024 | $4,909 | OP |
00010995 | 18 | 3/4/2024 0:00 | 3 | 2024 | $159 | OP |
00011000 | 6 | 3/7/2024 0:00 | 3 | 2024 | $598 | OP |
00011001 | 22 | 3/7/2024 0:00 | 3 | 2024 | $4,111 | OP |
00000298 | 23 | 3/18/2024 0:00 | 3 | 2024 | $99,450 | UO |
00011017 | 10 | 3/18/2024 0:00 | 3 | 2024 | $126 | OP |
00011021 | 10 | 3/19/2024 0:00 | 3 | 2024 | $75 | OP |
00011035 | 16 | 3/22/2024 0:00 | 3 | 2024 | $160 | OP |
00011036 | 8 | 3/22/2024 0:00 | 3 | 2024 | $883 | OP |
00001042 | 15 | 3/25/2024 0:00 | 3 | 2024 | $93,600 | UO |
00001042 | 25 | 3/25/2024 0:00 | 3 | 2024 | $13,985 | UO |
00001042 | 26 | 3/25/2024 0:00 | 3 | 2024 | $76,290 | UO |
00011037 | 7 | 3/25/2024 0:00 | 3 | 2024 | $3,138 | OP |
00011037 | 11 | 3/25/2024 0:00 | 3 | 2024 | $127 | OP |
00011037 | 12 | 3/25/2024 0:00 | 3 | 2024 | $215 | OP |
00011037 | 13 | 3/25/2024 0:00 | 3 | 2024 | $585 | OP |
00011037 | 14 | 3/25/2024 0:00 | 3 | 2024 | $886 | OP |
00011037 | 18 | 3/25/2024 0:00 | 3 | 2024 | $1,590 | OP |
00011037 | 19 | 3/25/2024 0:00 | 3 | 2024 | $1,877 | OP |
00011037 | 21 | 3/25/2024 0:00 | 3 | 2024 | $3,513 | OP |
00001043 | 24 | 3/26/2024 0:00 | 3 | 2024 | $274,560 | UO |
00011048 | 1 | 3/27/2024 0:00 | 3 | 2024 | $1,663 | OP |
00011048 | 2 | 3/27/2024 0:00 | 3 | 2024 | $625 | OP |
00011048 | 3 | 3/27/2024 0:00 | 3 | 2024 | $1,218 | OP |
00011048 | 4 | 3/27/2024 0:00 | 3 | 2024 | $5,884 | OP |
00011048 | 5 | 3/27/2024 0:00 | 3 | 2024 | $1,053 | OP |
00011048 | 10 | 3/27/2024 0:00 | 3 | 2024 | $50 | OP |
00011048 | 17 | 3/27/2024 0:00 | 3 | 2024 | $26 | OP |
00011048 | 20 | 3/27/2024 0:00 | 3 | 2024 | $13 | OP |
Hi @ahoggatt42 ,
Based on your description, I created three tables and created relationships for them.
Subsequently a measure similar to the one in your description was written and it gave the correct results.
Measure =
VAR test1 =
CALCULATE(SUM('Table A'[Price]),FILTER(ALL('Table A'),'Table A'[date] = MAX('Table A'[date]) && 'Table A'[Type] = "A"))
VAR test2 =
CALCULATE(SUM('Table B'[Price]),FILTER(ALL('Table B'),'Table B'[date] = MAX('Table B'[date]) && 'Table B'[Type] = "A"))
RETURN
test1 + test2
Therefore, please confirm whether the direct relationship between your tables is correct. Another thing to note is that the date of the intermediate table should be placed in the visual object, which is the Bookings Goal table in your description.
Alternatively, there is a way to get the results you want, which requires building a calculation sheet.
Table =
UNION(SELECTCOLUMNS(
FILTER('Table A','Table A'[Type] = "A"),
"MyDate",'Table A'[date],
"MyPrice",'Table A'[Price]),
SELECTCOLUMNS(
FILTER('Table B','Table B'[Type] = "A"),
"MyDate",'Table B'[date],
"MyPrice",'Table B'[Price]))
Then create measure and perform summation.
Measure 2 =
CALCULATE(SUM('Table'[MyPrice]),FILTER('Table','Table'[MyDate] = MAX('Table'[MyDate])))
If your Current Period does not refer to this, please clarify in a follow-up reply.
Best Regards,
Clara Gong
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thanks for your reply. I think I need to clarify what my expected outcome is. If I use your sample (For simplicity) I would expect something like this:
1/1/2024 | 20 |
1/2/2024 | 31 |
1/3/2024 | 64 |
1/5/2024 | 125 |
1/6/2024 | 140 |
Based on what you have on your relationships that is how I have mine set up as well. I can put together some samples of my data if that would help.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
113 | |
104 | |
77 | |
67 | |
63 |
User | Count |
---|---|
144 | |
107 | |
105 | |
82 | |
69 |