Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now
Hello,
I have two data tables, one (I'll call it table 1) for occurrences by date, product, production line, and how long it lasted. And another one with the campaign with start and end date, line and product (I'll call it table 2)
I need to sum the amount of time those occurrences lasted by campaing.
I tried assigning for each occurrence a code for it's campaing ("line & product code & startdate"). But couldn't make it work, needed to check the line and product combination and if the date of the occurrence was in the interval of the campaign. Another way was to filter by this two conditions directly at the campaign table on a new column.
But still, I don't know how it could be done.
Could somebody help me with this problem, pls?
Thanks!
Solved! Go to Solution.
This calculated column formula in the Campaigns table works
=CALCULATE(SUM(Occurences[Duration]),FILTER(Occurences,Occurences[Line]=EARLIER(Campaign[Line])&&Occurences[Product]=EARLIER(Campaign[Product])&&Occurences[Date]>=EARLIER(Campaign[Start date])&&Occurences[Date]<=EARLIER(Campaign[End Date])))
Hope this helps.
Here are some examples of the tables, can't provide exactly the data, but these examples are similars.
I expect to insert the campaign code (some kind of identifier as the example bellow) in a new column on table 1, this way I can then add the durations to the campaigns. And even do more connections after.
OR
Create a new column on table 2 already adding the duration of occurrences from table 1 of that campaign.
Dates in the format - dd/mm/yy hh:mm
Table 1 of occurrences:
Line | Date | Product | Duration (Min) | Campaign code |
11 | 4/3/22 17:05 | 4945 | 5 | "some kind of identifier" |
11 | 4/3/22 18:30 | 4945 | 2 | "ex: 11-4945-03/03/2022 06:00" |
12 | 4/3/22 18:30 | 567244 | 3 | ? |
11 | 4/3/22 19:00 | 4945 | 5 | ? |
13 | 4/3/22 19:10 | 532277 | 10 | ? |
11 | 5/3/22 6:02 | 5051 | 7 | ? |
13 | 5/3/22 6:05 | 532277 | 2 | ? |
Table 2 of campaigns:
Line | Product | Start date | End date | Sum of duration |
11 | 4945 | 24/2/22 9:00 | 5/3/22 6:00 | ? |
12 | 567244 | 26/2/22 8:00 | 15/3/22 6:00 | ? |
13 | 532277 | 26/2/22 8:00 | 6/3/22 9:00 | ? |
11 | 5051 | 5/3/22 6:00 | 7/3/22 6:00 | ? |
You can see in the example a campaign change, but more complex things could happen, products being made ate different lines, even at the same time. This is why I think that a identifier with the combination of #LINE, #product and #startdate will be used...
I hope this make my problem clearer, it's my first time posting here.
Thanks for your time and help!
Hi, It seems your second table has the product and line fields. All you need to do is create a relationship between table 1 and table 2 on the common fields like Line or Product.
Doing so will allow your fields from tablw 2 to be related to table 1.
After creating the relationship you can create a table with Campaign, Product and Sum of [how long occurences lasted] to get your result.
I have a variety of products, 14 lines and the campaigns last only some days, therefore, I have many entries for campaigns, and some products repeat themselfs on the same line duing the year. Therefore, I needed something like I explained:
- Relate the occurence to a campaign using the variables -> line, product and start date. (Pulling data from table 2 into table 1)
or
- Relate the campaign to multiple occurrences and sum the duration value given in table 1, using the variables -> line, product and the occurrence date, that should be recognized as between start and end date of the campaign (Pulling data from table 1 to table 2)
I have line and product on both tables, on table 1 I have the occurence date and duration; and on table 2 I have the start and end of the campaign.
Don't know if I made my problem clear or If any other information could help.
Hi @ojferreira ,
I think I understand your issue. Have you tried to create a column to act as an identifier?
You can CONCAT(Line,product) on each table and use that as a key to join your tables. If needed you can also concat your sections or other fields as well that you need to create one column of all information.
Then you can use that newly created field to act as a field for relationship between the two tables. This will help you relate to multiple fields per your requirement.
If this doesn't help, can you share a screenshot of what your ideal result would look like?
Thanks!
Hi,
Share some data and show the expected result.
Here are some examples of the tables, can't provide exactly the data, but these examples are similars.
I expect to insert the campaign code (some kind of identifier as the example bellow) in a new column on table 1, this way I can then add the durations to the campaigns. And even do more connections after.
OR
Create a new column on table 2 already adding the duration of occurrences from table 1 of that campaign.
Dates in the format - dd/mm/yy hh:mm
Table 1 of occurrences:
Table 2 of campaigns:
You can see in the example a campaign change, but other things could happen that should be considered, products being made ate different lines, even at the same time. This is why I think that a identifier with the combination of #LINE, #product and #startdate will be used...
I hope this make my problem clearer, it's my first time posting here.
Thanks for your time and help!
Hi,
Share the 2 tables in a format that can be pasted in an MS Excel file.
Here.
Table 1 of occurrences:
Line | Date | Product | Duration |
11 | 04/03/2022 17:05 | 4945 | 5 |
11 | 04/03/2022 18:30 | 4945 | 2 |
12 | 04/03/2022 18:30 | 567244 | 3 |
11 | 04/03/2022 19:00 | 4945 | 5 |
13 | 04/03/2022 19:10 | 532277 | 10 |
11 | 05/03/2022 06:02 | 5051 | 7 |
13 | 05/03/2022 06:05 | 532277 | 2 |
Table 2 of campaigns:
Line | Product | Start date | End Date | Sum of duration |
11 | 4945 | 24/02/2022 | 05/03/2022 | |
12 | 567244 | 26/02/2022 | 15/03/2022 | |
13 | 532277 | 26/02/2022 | 06/03/2022 | |
11 | 5051 | 05/03/2022 | 07/03/2022 |
This calculated column formula in the Campaigns table works
=CALCULATE(SUM(Occurences[Duration]),FILTER(Occurences,Occurences[Line]=EARLIER(Campaign[Line])&&Occurences[Product]=EARLIER(Campaign[Product])&&Occurences[Date]>=EARLIER(Campaign[Start date])&&Occurences[Date]<=EARLIER(Campaign[End Date])))
Hope this helps.
Ashish, Thank You!
But I'll need to filter by unique values on a column of the occurences table, how could I do that inside filter? I didn't antecipate that problem, was only focusing in the bigger one.
(explanation: these occurences can happen in one of the 3 parts of the machine, or in 2 of these 3, or in all of them, but it generates an entry for each part anyway) as bellow:
Table 1 of occurrences (image and table):
With the "duplicates" in yellow above.
Line | Date | Product | Duration | Section | Cavity | Identifier |
11 | 04/03/2022 17:05 | 4945 | 5 | 2 | A | 112-44624,7118055556 |
11 | 04/03/2022 17:05 | 4945 | 5 | 2 | B | 112-44624,7118055556 |
11 | 04/03/2022 18:30 | 4945 | 2 | 3 | A | 113-44624,7708333333 |
12 | 04/03/2022 18:30 | 567244 | 3 | 10 | A | 1210-44624,7708333333 |
12 | 04/03/2022 18:30 | 567244 | 3 | 10 | B | 1210-44624,7708333333 |
12 | 04/03/2022 18:30 | 567244 | 3 | 10 | C | 1210-44624,7708333333 |
11 | 04/03/2022 19:00 | 4945 | 5 | 5 | A | 115-44624,7916666667 |
13 | 04/03/2022 19:10 | 532277 | 10 | 1 | A | 131-44624,7986111111 |
11 | 05/03/2022 06:02 | 5051 | 7 | 3 | A | 113-44625,2513888889 |
11 | 05/03/2022 06:02 | 5051 | 7 | 3 | B | 113-44625,2513888889 |
13 | 05/03/2022 06:05 | 532277 | 2 | 4 | A | 134-44625,2534722222 |
I can't delete those rows because it's important to know which cavities were affected.
But to sum the duration, I want only the duration for each section.
I used an identifier to count the distinct occurences, but for the sum of duration I don't know how to do it.
Can I use values or distinct in this case?
=CALCULATE(SUM(Occurences[Duration]),FILTER(Occurences,Occurences[Line]=EARLIER(Campaign[Line])&&Occurences[Product]=EARLIER(Campaign[Product])&&Occurences[Date]>=EARLIER(Campaign[Start date])&&Occurences[Date]<=EARLIER(Campaign[End Date])&&Values(Occurrences[Identificator])))
It doesn't seem to work or I don't know how to apply it.
Cannot understand your requirement at all.
I need another filter for unique values in the table occurences, I have an identifier column that I created with concat. (&) on the occurences table.
Can you help me?
Had i understood your question, i would have answered it earlier itself.
How may I help you understanding? I don't know how else to explain it 😕
(There is also a language barrier where some information might be getting lost)
Check out the October 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
113 | |
89 | |
84 | |
76 | |
64 |
User | Count |
---|---|
135 | |
112 | |
98 | |
98 | |
92 |