Forum Discussion

ksball13's avatar
ksball13
New Member
6 years ago
Solved

New User- DAX Question

Hi, I am relatively new to Power BI and am working on some reports for my company:

 

We are a freight company and we measure activity (loads moved) based on Pickup Date.  

 

In my data table, each load  has a Customer attached to it.   For that Customer there is an associated  record for "First Load Moved date" and "Sales Rep"

 

Over a given period of time in my slicer (Pickup Date being the time), I want to know how many New Customers a Sales Rep earned.   Specifically, how many Customers had their "First Loads Moved Date" within the time period that I am measuring (related to the Pickup Date.).

 

I am struggling with figuring out a DISTINCTCOUNT function that ties it together and would love any help.

 

 

  • Anonymous's avatar
    Anonymous
    6 years ago

    Hi ksball13 ,

     

     

    Try this measure.

     

    Measure = 
    CALCULATE (
        DISTINCTCOUNT ( 'Table'[CustomerID] ),
        FILTER (
          Dates,
            Dates[Date] >= MIN( 'Table'[PickupDate] )
                && Dates[Date] <= MAX ( 'Table'[PickupDate] )
        )
    )

     

    Incase it does not work, please share sample data and your expected output.

     


    Regards,

    Harsh Nathani


    Appreciate with a Kudos!! (Click the Thumbs Up Button)

    Did I answer your question? Mark my post as a solution!

     

     

3 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi ksball13 ,

     

     

    Try this measure.

     

    Measure = 
    CALCULATE (
        DISTINCTCOUNT ( 'Table'[CustomerID] ),
        FILTER (
          Dates,
            Dates[Date] >= MIN( 'Table'[PickupDate] )
                && Dates[Date] <= MAX ( 'Table'[PickupDate] )
        )
    )

     

    Incase it does not work, please share sample data and your expected output.

     


    Regards,

    Harsh Nathani


    Appreciate with a Kudos!! (Click the Thumbs Up Button)

    Did I answer your question? Mark my post as a solution!

     

     

    • ksball13's avatar
      ksball13
      New Member

      Anonymous 

       

      That DID work once I replaced Dates[Date] with my "first load moved" date.   Thank you so much!

       

      Follow up question: 

       

      Let's say I have two levels of Sales Person.   I call them "Account Rep" and "BDM"   

       

      In many cases, the  Customer has a BDM and an Account Rep.   Many times the BDM and the Account Rep have the same value (it is the same person acting in both capacities).  

       

      I then want to take my new field and break that down into two measures:

       

      1. New Customers Added when the AR and the BDM are the same.

      2.  New Customers Added when the AR and the BDM are different.

       

      How would I go about creating those measures?