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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
zs6rop
New Member

Count the number of records where a planned dated changed between two dates

Hi All

 

I am creating a report where I need to see how many items (records) have had the Planned End Date changed in a certain time period (based on filters).

Any advise on how to do this, and effectiveness of my measures.

 

I have these measures:

Planned End Date - Range Latest =

// Find Planned End for the Last Selected Snapshot
Var vDate =
   IF(
      ISFILTERED(SnapshotDates),
         CALCULATE(
             MAX(SnapshotDates[SnapshotDate]),
             FILTER(SnapshotDates, SnapshotDates[SnapshotDate])
        ),
       CALCULATE(
         MAX(SnapshotDates[SnapshotDate]),
         ALL(SnapshotDates)
      )
   )
VAR vRetval =
   CALCULATE(
      SELECTEDVALUE(T_Items[PlannedEndDate]),
      FILTER(T_Items,T_Items[SnapshotDate]=vDate)
   )
Return vRetval


Planned End Date - Range Original =
// Find Planned End for the First Selected Snapshot
Var vDate =
   IF(
      ISFILTERED(SnapshotDates),
         CALCULATE(
             MIN(SnapshotDates[SnapshotDate]),
             FILTER(SnapshotDates, SnapshotDates[SnapshotDate])
        ),
       CALCULATE(
         MAX(SnapshotDates[SnapshotDate]),
         ALL(SnapshotDates)
      )
   )
VAR vRetval =
   CALCULATE(
      SELECTEDVALUE(T_Items[PlannedEndDate]),
      FILTER(T_Items,T_Items[SnapshotDate]=vDate)
   )
Return vRetval

Planned End Date Shift Months =
// Determine The number of Months Shifted

 

Var vRetval = DATEDIFF([Planned End Date - Range Original],[Planned End Date - Latest],MONTH)
Return if(vRetval<>0,vRetval)

 

Planned End Dates Changed =
// Determine if the End Date Shifted
IF([Planned End Date Shift Months] <> 0, "Yes","No")

 

On a weekly basis, the table (T_Items), id getting data by means of a job running and effectivly creating a snapshot of the transactional table.  Below is an example of the table with sample data.

 

Let's say my snapshot Start Date is 8 Jan 21 and the End date is 22 Jan 21, then 

The output I am seaking is twofold:

1. A table view indicating if the Item (ID) had a Pland End Date Changed, e.g. below:

IDPlanned Dated Changed
1Yes
2No
3Yes

 

2. Number of items that had a change (This is where I need some help😞 

Yes2
No1

 

T_Items

IDPlannedEndDateSnapshot
1 01 Jan 21
105 Feb 2108 Jan 21
105 Feb 2115 Jan 21
110 Feb 2122 Jan 21
110 Feb 2129 Jan 21
2 01 Jan 21
201 Mar 2108 Jan 21
201 Mar 2115 Jan 21
201 Mar 2122 Jan 21
215 Mar 2129 Jan 21
301 Jun 2115 Jan 21
315 May 2122 Jan 21
315 May 2129 Jan 21

 

 

1 ACCEPTED SOLUTION
zs6rop
New Member

@amitchandak , for my spesific need, I had to tweak your formula to:

COUNTX(
FILTER(
SUMMARIZE(
FILTER(T_ITEMS,
// Only Look at reords that do have a Planned End Date
NOT(ISBLANK(T_ITEMS[PlannedEndDate]))
),
//group by
T_ITEMS[ID],
//Custom Col
"UEDCnt", DISTINCTCOUNT(T_ITEMS[PlannedEndDate])
),
[UEDCnt] > 1
), T_ITEMS[ID]
)

 

I am now getting what I am looking for

View solution in original post

3 REPLIES 3
zs6rop
New Member

@amitchandak , for my spesific need, I had to tweak your formula to:

COUNTX(
FILTER(
SUMMARIZE(
FILTER(T_ITEMS,
// Only Look at reords that do have a Planned End Date
NOT(ISBLANK(T_ITEMS[PlannedEndDate]))
),
//group by
T_ITEMS[ID],
//Custom Col
"UEDCnt", DISTINCTCOUNT(T_ITEMS[PlannedEndDate])
),
[UEDCnt] > 1
), T_ITEMS[ID]
)

 

I am now getting what I am looking for

amitchandak
Super User
Super User

@zs6rop , Try a measure like

 

countx(filter(Summarize(Table, Table[ID], "_dis", distinctcount(Table[PlannedEndDate])) ,[_1]>1),[ID])

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi, thanks.  This is so clever, I did not think about doing a distinct count on the Planned End Date.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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