Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

comparing dates in two tables

Good Afternoon

 

I am new to power bi and need some help please

 

I need to compare dates from two tables, event table and sign up table.

Event date and Sign Up date

Tables are joined many to one cardinality with single cross filter direction on a NamePk (name + Address)

 

The issue i have is that people can sign up to a course prior to the event and can sign up to multiple courses and i want to ascertain how many distinct people signed up to a course following the event.

 

I have the following to ascertain if a person has signed up to an event but this includes where the date is prior to the event date.

Applied =
if('event_date_Attendees'[NamePK] in DISTINCT('Sign_Up'[NamePK]), 1,0)

 

Thank you for your help

 

  • Hi,

    In Table1, write this calculated column formula

    App date = lookupvalue('Table 2'[Application date],'Table 2'[Name],'Table 1'[Name])

    Write this measure and drag it to a card visual

    Measure = countrows(filter(values('Table 1'[Name]),'Table 1'[Event_date]>='Table 1'[App date]))

    Hope this helps.

5 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous,

    Can you please share a pbix or some dummy data that keep the raw data structure with expected results? It should help us clarify your scenario and test to coding formula.

    How to Get Your Question Answered Quickly  

    Regards,

    Xiaoxin Sheng

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi see below example of what is in each table. The name will only appear once in table one but can appear multiple times in table 2.

       

      Table 1     
      Event DateNameAddressArea Interested inNamePK 
      10/10/2022aaaaaaaapprenticeaa - aaaaa 
      10/10/2022bbbbbbbapprenticebb - bbbbb 
      10/10/2022ccccccca levelcc - ccccc 
      10/10/2022ddddddda leveldd - ddddd 
            
            
            
      Table 2     
      Application DateNameAddressCourse CodeNamePK 
      11/10/2022aaaaaaa1aa - aaaaa 
      11/10/2022aaaaaaa2aa - aaaaa 
      20/10/2022bbbbbbb1bb - bbbbb 
      10/10/2022ccccccc1cc - ccccc 
      10/10/2022ccccccc25cc - ccccc 
      09/10/2022eeeeeee3ee - eeeeee 
            
            
      • Ashish_Mathur's avatar
        Ashish_Mathur
        Super User

        Hi,

        In Table1, write this calculated column formula

        App date = lookupvalue('Table 2'[Application date],'Table 2'[Name],'Table 1'[Name])

        Write this measure and drag it to a card visual

        Measure = countrows(filter(values('Table 1'[Name]),'Table 1'[Event_date]>='Table 1'[App date]))

        Hope this helps.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi please see below sample data

     

    event dateapplication datecustomer idcourse id
    12/10/202212/10/202211
    12/10/202213/10/202212
    12/10/202225/09/202221
    12/10/202212/10/202231
    12/10/202215/10/202242
    12/10/202201/10/202251
    12/10/202213/10/202252
    12/10/202212/10/202261
    12/10/202211/10/202263
    12/10/202212/10/202273
    12/10/202213/10/202284

     

    What i want to count is how many people (distinct count) who attended the event applied either on the same day of the event or the following day. 

    event date and application date are in two separate tables, course id is in the application table and customer id is in both. 

    Tables are joined many to one cardinality with single cross filter direction on a NamePk (name + Address)

    • Ashish_Mathur's avatar
      Ashish_Mathur
      Super User

      Hi,

      Share the different tables that you have.  Else, share the download link of your PBI file.