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
ErickMontiel
New Member

Count the IDs accumulated

Hello everyone,

 

Could you please help me with the following?

 

The following table has an ID and finish date when one ID wasn't finish the closed date is blank. Now I want to count the lines that are in blank in the previous days according to the finish date like the example on the table:

 

ErickMontiel_0-1711562730306.png

 

4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hi,

Write this calculated column formula

Column = COALESCE(CALCULATE(COUNTBLANK(Data[Closed Date]),FILTER(Data,Data[Finish Date]<EARLIER(Data[Finish Date]))),0)

Hope this helps.

Ashish_Mathur_0-1711583195718.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
AnalyticsWizard
Solution Supplier
Solution Supplier

Certainly! Let’s break down the task step by step:

  1. Understanding the Problem:

    • You have a table with columns: ID, Finish Date, and Closed Date.
    • When an ID is not finished (Closed Date is blank), you want to count the number of lines (rows) with blank Closed Dates that occurred before each respective Finish Date.
  2. Approach:

    • We’ll create a new column called Accumulated that represents the count of blank Closed Dates before each Finish Date.
    • For each row, we’ll calculate this accumulated count based on the Finish Date.
  3. Solution:

    • Let’s assume your table is named MyTable.
    • We’ll use DAX (Data Analysis Expressions) to create the new column.
  4. DAX Formula:

    • In Power BI Desktop, go to the Model View.
    • Right-click on your table (e.g., MyTable) and select New Column.
    • Enter the following DAX formula:
      Accumulated =
      VAR CurrentFinishDate = MyTable[Finish Date]
      RETURN
          CALCULATE(
              COUNTROWS(MyTable),
              FILTER(
                  MyTable,
                  MyTable[Finish Date] = CurrentFinishDate &&
                  ISBLANK(MyTable[Closed Date])
              )
          )
    • This formula calculates the count of rows where the Finish Date matches the current row’s Finish Date and the Closed Date is blank.
  5. Explanation:

    • We use a VAR to store the current row’s Finish Date.
    • The CALCULATE function counts rows based on the specified conditions.
    • The FILTER function filters the table to include only rows with the same Finish Date and blank Closed Date.
  6. Result:

    • Your new column Accumulated will show the count of blank Closed Dates before each Finish Date.

Here’s how the first few rows of your updated table might look:

ID Finish Date Closed Date Accumulated
111/23/202311/23/20230
211/23/2023Blank0
311/23/202311/23/20230
411/24/202311/24/20231

Remember to adjust the table and column names according to your actual data. If you encounter any issues or need further assistance, feel free to ask! 😊

Hello, thank you for the help.

I put the formula and it calculates the blank lines but for the same date, not the blank lines for previous dates. Could you help me again?

Hi @ErickMontiel 

 

The line inside FILTER that compares 

MyTable[Finish Date] = CurrentFinishDate

 

should be

MyTable[Finish Date] <= CurrentFinishDate

 

or

MyTable[Finish Date] < CurrentFinishDate

 

Let me know how this goes.



Proud to be a Super User!

daxformatter.com makes life EASIER!

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!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

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.