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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
ladyy27
Regular Visitor

SUMMARIZE with COUNT column

Hey guys, I'm a complete newbie in Power BI so I'll really appreciate your help.

I have a query of registrations:

REGISTRATION-IDPERIODENROLLMENT-DATEPAYMENT-DATEPAYMENT-STATUSPAYMENT-DAY
2591453OCT/2019 - FEB/20206/1/196/1/19Paid-2
2591454OCT/2019 - FEB/20206/1/196/1/19Paid-2
2701697OCT/2019 - FEB/20206/2/196/2/19Paid-1
3199960OCT/2019 - FEB/20206/3/19 Not Paid 
3202534OCT/2020 - FEB/20216/1/206/1/20Paid-2
3202535OCT/2020 - FEB/20216/2/206/2/20Paid-1
3202502OCT/2020 - FEB/20216/2/206/2/20Paid-1
3203150OCT/2020 - FEB/20216/3/20 Not Paid 

"PAYMENT-DAY" is a calculated column that contains the number of days that have passed from the beginning of registrations in each period in countdown format where the last day of registrations in that period is the zero-day. This DAX formula is working fine.

I need to get a table visualization which includes:

  • The period name (more than 1)
  • Payment day
  • Number of paid registrations per payment day
  • Cumulative number of paid registrations (differenced by period)

Like this:

PERIODPAYMENT-DAYNumber-of-paid-registrations-per-payment-dayCumulative-number-of-paid-registrations
OCT/2019 - FEB/2020-222
OCT/2019 - FEB/2020-113
OCT/2020 - FEB/2021-211
OCT/2020 - FEB/2021-123

In order to this, I created an aggregated table with SUMMARIZE:

 

CUMULATIVE-PAYMENTS = SUMMARIZE(
'REQUESTS','REQUESTS'[PERIOD],
'REQUESTS'[PAYMENT-DAY],
"Number-of-paid-registrations-per-payment-day",COUNTA('REQUESTS'[PAYMENT-STATUS])
)

 

After, I added a measure to this new aggregated table for the Cumulative number of paid registrations with this DAX formula:

 

Cumulative-number-of-paid-registrations = CALCULATE(
SUM(
'CUMULATIVE-PAYMENTS'[Number-of-paid-registrations-per-payment-day]),
FILTER(
ALLEXCEPT('CUMULATIVE-PAYMENTS','CUMULATIVE-PAYMENTS'[PERIOD]),
'CUMULATIVE-PAYMENTS'[PAYMENT-DAY] <= MAX('CUMULATIVE-PAYMENTS'[PAYMENT-DAY])
)
)

 

But the results aren't correct, the table visualization shows what I assume like "Payment Days" that don't have paid registrations (Not Paid). Consequently, it shows the wrong "Number of paid registrations" and wrong "Cumulative number of paid registrations".

Any suggestions or alternatives to solve this problem?

Thanks!

2 REPLIES 2
amitchandak
Super User
Super User

@ladyy27 , Try like one of the two

Cumulative-number-of-paid-registrations = CALCULATE(
SUM(
'CUMULATIVE-PAYMENTS'[Number-of-paid-registrations-per-payment-day]),
FILTER(
ALL('CUMULATIVE-PAYMENTS'),
'CUMULATIVE-PAYMENTS'[PAYMENT-DAY] <= MAX('CUMULATIVE-PAYMENTS'[PAYMENT-DAY])
&& 'CUMULATIVE-PAYMENTS'[PERIOD] = max('CUMULATIVE-PAYMENTS'[PERIOD]))
)

/////or 
Cumulative-number-of-paid-registrations = CALCULATE(
SUM(
'CUMULATIVE-PAYMENTS'[Number-of-paid-registrations-per-payment-day]),
FILTER(
ALLSELECTED('CUMULATIVE-PAYMENTS'),
'CUMULATIVE-PAYMENTS'[PAYMENT-DAY] <= MAX('CUMULATIVE-PAYMENTS'[PAYMENT-DAY])
)
)
Greg_Deckler
Super User
Super User

@ladyy27 - First welcome. Thanks for posting what you desire as output, very important. But, to understand what is going on, would need to understand your source data. Posting it as text in a table is extremely helpful. 

 

Please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.