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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Thrasso00
Frequent Visitor

How many were 'Closed' at given date

Hi I have two tables the firstone is a changelog called 'Activity' the second one is a table called 'Dates' wich dertermines the deadlines by zone.

This is an extract of the first table

IndexTimeStampIssueActionZONE_JCS
112-03-21EditedZ09
109-03-21ReactivatedZ09
123-11-22ReopenedZ09
114-04-21ReopenedZ09
113-04-21ClosedZ09
106-04-21EditedZ09
124-02-21EditedZ09
103-03-21EditedZ09
222-04-21EditedZ03
219-02-21ReactivatedZ03
219-02-21ResolvedZ03
219-02-21ResolvedZ03
204-03-21EditedZ03
226-02-21EditedZ03
209-03-21ClosedZ03
223-02-21EditedZ03
217-02-21CreatedZ03
225-02-21EditedZ03


This is the whole second one

ZONEPLANNING
Z0118-09-21
Z0204-08-21
Z0305-12-22
Z0406-12-22
Z0507-12-22
Z0608-12-22
Z0709-12-22
Z0810-12-22
Z0911-12-22
Z1012-12-22
Z1113-12-22
Z1214-12-22
Z1315-12-22
Z1416-12-22
Z1517-12-22
Z1618-12-22
Z1719-12-22


I'm trying to add a 3rd colonne in the second table with the values of the closed 'Index' at the given date by the 'Planning' column for every zone.
If I had to acomplish these task manually I'd proceed as follows:
1. I filter the table 'Activity' by Zone
2. Filter the table 'Activity ' by 'TimeStamp' taking only dates before the date given by the "Planning" and "Zone".
3. Take the earliest TimeStamp of every Index.
4. Count the total number of filtered rows whose 'IssueAction' is equal to 'Closed'
5. Repeat the same operation for each Zone.

I have written this DAX code but it seems to be filtering the 'IssueAction' before taking the earliest date of every 'Index'.

 

newColumn = 
VAR currZone = Dates[ZONE]
VAR currDate = Dates[Planning]
RETURN
CALCULATE(
    DISTINCTCOUNT('Activity (P-B6G-CIV-BGTF)'[Index]),
    FILTER(
        'Activity (P-B6G-CIV-BGTF)',
        'Activity (P-B6G-CIV-BGTF)'[Zone_JCS] = currZone &&
        'Activity (P-B6G-CIV-BGTF)'[TimeStamp] <= currDate &&
        'Activity (P-B6G-CIV-BGTF)'[IssueAction] = "Closed" &&
        'Activity (P-B6G-CIV-BGTF)'[TimeStamp] =
            CALCULATE(
                MIN('Activity (P-B6G-CIV-BGTF)'[TimeStamp]),
                'Activity (P-B6G-CIV-BGTF)'[Index] = EARLIER('Activity (P-B6G-CIV-BGTF)'[Index])
            )
    )
)

 

Could somebody help me please?

8 REPLIES 8
Thrasso00
Frequent Visitor

My first explanation was perhaps a little complex.
I have created two simplified tables to try to make my explanation clearer.
Hi I have a two table in Power BI.
Table 'Activity':

Thrasso00_0-1680986581260.png

The other table is called 'Dates':

Thrasso00_1-1680986673840.png

I need to add a column in the Dates table called 'Closed Issues at planning date by zone':
The resulting column is the result of using the Planning dates in Dates table as a cutoff date. After that we take the moste recent date in the 'DateOfIssueAction' of each Issue with the same number and the same Zone. After that we take the number of lines with the word 'Closed' in the IssueAction field.
The resulting table after adding the new column would be this:

Thrasso00_2-1680986815185.png

Does anyone have any idea how to do it with DAX or Power Query?
I leave the simplified file in the following link:
https://we.tl/t-GK6hssGVPN

Thank you in advance.

FreemanZ
Super User
Super User

hi @Thrasso00 

try like:

newColumn = 
VAR currZone = Dates[ZONE]
VAR currDate = Dates[Planning]
VAR MinIndex = 
CALCULATE(
MIN('Activity (P-B6G-CIV-BGTF)'[TimeStamp]),
'Activity (P-B6G-CIV-BGTF)'[Index] = EARLIER('Activity (P-B6G-CIV-BGTF)'[Index])
)
RETURN
CALCULATE(
    DISTINCTCOUNT('Activity (P-B6G-CIV-BGTF)'[Index]),
    FILTER(
        'Activity (P-B6G-CIV-BGTF)',
        'Activity (P-B6G-CIV-BGTF)'[Zone_JCS] = currZone &&
        'Activity (P-B6G-CIV-BGTF)'[TimeStamp] <= currDate &&
        'Activity (P-B6G-CIV-BGTF)'[IssueAction] = "Closed" &&
        'Activity (P-B6G-CIV-BGTF)'[TimeStamp] =MinIndex
    )
)

Hi @FreemanZ,
Thank you for helping.
I get this message:

Thrasso00_0-1680852546257.png

I don't understand why.

hi @Thrasso00 

could you enrich your data of Activity table to better reflect your case?

Is it not allowed to provide the two excel files in this forum?

Does anyone have an idea how to do this?
May be another approach?

@Thrasso00 

Upload to any cloud service like onedrive or dropbox and share the link

Hi @tamerj1,
See the link here.
https://we.tl/t-DKzeXIEio7

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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