Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Sibrulotte
Helper III
Helper III

Row level date range

Hi,

We have a model with email messages, send logs, contacts, and transactional data from sales.

Message:

Message Nom Message ID

webinaire envoie 11
webinaire envoie 22
webinaire envoie 33
webinaire envoie 44

 

Send Log: 

 

Message ID Sent_date Contact ID

118 janvier 202410
118 janvier 202420
118 janvier 202430
121 janvier 202440
29 février 202410
29 février 202440
210 février 202420
31 mars 202410
316 mars 202430
41 avril 202410
41 avril 202450
43 avril 202420
45 avril 202430
410 avril 202440

 

Contact:

Contact ID Epargnant id

10100
20200
30300
40400
50500

 

Transactional:

Epargnant_id date_report transaction_brut ind_adhesion

10025 janvier 20242001
10027 février 202430 
10029 mars 202450 
10015 avril 2024120 
20015 février 2024201
2004 mars 2024100 
20029 mars 202490 
20018 avril 202410 
3004 février 2024701
30029 février 2024130 
3004 mars 202420 
30019 mars 202490 
3004 avril 202440 
40025 janvier 2024201
40027 février 2024130 
40012 avril 202410 
50025 avril 20241001

 

 

We are looking to show sum of transaction brut from transactional data that has a Date_report that is within 14 days after the Sent_date only.

So our final matrix should look like:

Message

Amount

Webinaire Envoie 1

220

Webinaire Envoie 2

20

Webinaire Envoie 3

90

Webinaire Envoie 4

10

 

 

Webinaire Envoie 1 would be 220 because client 100 had a 200$ sale between January 18th 2024 and 14 days later --> February 1st and client 400 had 20$ sale between January 21st and February 4th. The sale from client 300 on February 4th should not count since his sent date was January 18th and the 14 day period would end February 1st. All the sales for client 200 also come after the 14 day period of him receiving the email.

 

 

We are fully aware that we might have over lapping reporting (webinaire 1 and 3 might be showing the same “amount” from the same client twice).

7 REPLIES 7
v-yaningy-msft
Community Support
Community Support

Hi, @Sibrulotte 

You can try the following method to solve the problem.

vyaningymsft_0-1713861532907.png

Steps:
1.Three consecutive Merges

vyaningymsft_1-1713861708095.png

2. Add costom column to calcute the date differ between [Transactional.date_report] and [Send Log.Sent_date]

vyaningymsft_4-1713861926020.png

 

vyaningymsft_2-1713861801085.png

3. Filter Date differ if the date differ between 0 and 14

vyaningymsft_3-1713861873394.png

4. Remove unneeded columns

vyaningymsft_5-1713861977843.png

5. Back to desktop, use the following measure.

vyaningymsft_6-1713862056109.png

transaction_brut_result = 
CALCULATE(SUM(ResultTable[Transactional.transaction_brut]))


Advanced Editor:

let
    Source = Table.NestedJoin(Message, {"Message ID"}, #"Send Log", {"Message ID"}, "Send Log", JoinKind.RightOuter),
    #"Expanded Send Log" = Table.ExpandTableColumn(Source, "Send Log", {"Message ID", "Sent_date", "Contact ID"}, {"Send Log.Message ID", "Send Log.Sent_date", "Send Log.Contact ID"}),
    #"Merged Queries" = Table.NestedJoin(#"Expanded Send Log", {"Send Log.Contact ID"}, Contact, {"Contact ID"}, "Contact", JoinKind.LeftOuter),
    #"Expanded Contact" = Table.ExpandTableColumn(#"Merged Queries", "Contact", {"Contact ID", "Epargnant id"}, {"Contact.Contact ID", "Contact.Epargnant id"}),
    #"Merged Queries1" = Table.NestedJoin(#"Expanded Contact", {"Contact.Epargnant id"}, Transactional, {"Epargnant_id"}, "Transactional", JoinKind.LeftOuter),
    #"Expanded Transactional" = Table.ExpandTableColumn(#"Merged Queries1", "Transactional", {"Epargnant_id", "date_report", "transaction_brut", "ind_adhesion"}, {"Transactional.Epargnant_id", "Transactional.date_report", "Transactional.transaction_brut", "Transactional.ind_adhesion"}),
    #"Added Custom" = Table.AddColumn(#"Expanded Transactional", "Custom", each [Transactional.date_report] - [Send Log.Sent_date]),
    #"Filtered Rows" = Table.SelectRows(#"Added Custom", each [Custom] >= #duration(0, 0, 0, 0) and [Custom] <= #duration(14, 0, 0, 0)),
    #"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"Message ID", "Send Log.Message ID", "Send Log.Sent_date", "Send Log.Contact ID", "Contact.Contact ID", "Contact.Epargnant id", "Transactional.Epargnant_id", "Transactional.date_report", "Transactional.ind_adhesion", "Custom"})
in
    #"Removed Columns"

 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

Hi @v-yaningy-msft ,

unfortunatly the first steps cannot be done properly. There are more than one sent date per transaction. 

That will multiply my transaction table like crazy. Not doable.

Hi, @Sibrulotte 

You can share the pbix file without sensitive data for testing by Google Drive. 

Best Regards,
Yang
Community Support Team

It's very unfortunate but my organisation does not allow it. 

Here is a sharefile link instead:

 

https://fondsftq.sharefile.com/d-s776bd94338064f10ad8e262d593f09f6

Hi, @Sibrulotte 

The link you shared requires a login to personal account in order to open it, which is not allowed due to security and privacy policy considerations, are you able to share links that can be opened without logging into personal account? (Google Drive can do this)

vyaningymsft_0-1714627454622.png

 


Best Regards,
Yang
Community Support Team

Sibrulotte
Helper III
Helper III

I'd love to share the PBIX file, but not sure of the best way.

Sibrulotte
Helper III
Helper III

Hi my message was marked as spam and is just getting posted, so I'm bringing it back to the top for your attention. Thank you 🙂

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.