Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

COUNTA and SUM for different periods

Hi All!

 

It's me again.. lol

This time I'm trying to build a report to show how many different payment terms we have by supplier at each period.

 

My database looks like this:

 

As ofWeekNumSupplierPayment term
10.aug.2033A30 days
10.aug.2033C60 days
10.aug.2033Y30 days
10.aug.2033A90 days
10.aug.2033Y75 days
10.aug.2033Z120 days
10.aug.2033Y45 days
17.aug.2034A60 days
17.aug.2034B30 days
17.aug.2034T90 days
17.aug.2034Y75 days
17.aug.2034U120 days
17.aug.2034B45 days
17.aug.2034Y60 days
17.aug.2034U30 days

 

The output i'm looking for is:

 

Number of payment termsNumber of suppliers
Week 33 
12
21
31
Week 34 
12
23

 

I've been trying to do that through a New Column and Measure.. but failed on both!

Absolutely no clue about this one..Can you help me with this one additional question?? 😁

 

Thanks again for the support!

  • This one is a little trickier.  To do it, you need to first make a disconnected table to hold the possible values for number of terms with an expression like this.  On the modelling tab, click on New Table and enter the expression below.

     

    NumberOfTerms = GENERATESERIES(1,5,1)
     
    Once you have that table (no relationship needed to the other tables), make this measure
     
    SupplierCountTerms =
    VAR numterms =
    SELECTEDVALUE ( NumberOfTerms[Value] )
    RETURN
    COUNTROWS (
    FILTER (
    VALUES ( Terms[Supplier] ),
    CALCULATE ( DISTINCTCOUNT ( Terms[Payment term] ) ) = numterms
    )
    )
     
    Then make a matrix visual with the WeekNum column and the NumberOfTerms[Value] column on rows and the measure above on values to get this.
     
     

     

    If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

    Regards,

    Pat

     

     

3 Replies

  • mahoneypat's avatar
    mahoneypat
    Icon for Microsoft Employee rankMicrosoft Employee

    This one is a little trickier.  To do it, you need to first make a disconnected table to hold the possible values for number of terms with an expression like this.  On the modelling tab, click on New Table and enter the expression below.

     

    NumberOfTerms = GENERATESERIES(1,5,1)
     
    Once you have that table (no relationship needed to the other tables), make this measure
     
    SupplierCountTerms =
    VAR numterms =
    SELECTEDVALUE ( NumberOfTerms[Value] )
    RETURN
    COUNTROWS (
    FILTER (
    VALUES ( Terms[Supplier] ),
    CALCULATE ( DISTINCTCOUNT ( Terms[Payment term] ) ) = numterms
    )
    )
     
    Then make a matrix visual with the WeekNum column and the NumberOfTerms[Value] column on rows and the measure above on values to get this.
     
     

     

    If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

    Regards,

    Pat

     

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Awesome!! worked perfectly.

      Thanks again for the support.

  • Anonymous's avatar
    Anonymous
    Not applicable

    mahoneypat 

    Hello Pat! I was wondering if you could help me with this one too? 😁

     

    Thanks!