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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

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!

1 ACCEPTED SOLUTION
mahoneypat
Microsoft Employee
Microsoft 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.
 
 

terms.png

 

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

Regards,

Pat

 

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

3 REPLIES 3
mahoneypat
Microsoft Employee
Microsoft 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.
 
 

terms.png

 

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

Regards,

Pat

 

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Anonymous
Not applicable

Awesome!! worked perfectly.

Thanks again for the support.

Anonymous
Not applicable

@mahoneypat 

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

 

Thanks!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.