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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Arranafc19
Helper IV
Helper IV

Check if ID previously existed outside of date range

Hi,

 

Looking for some guidance on a measure I am working on , not sure where I am going wrong.

 

I am trying to look at a list of ids and get a distinct count of ids created within that time , however I need to be able to exclude any that have a previous record before my selected date range.

 

Arranafc19_0-1690976832385.png

 

looking at the above example , between the date range of 01/08 and 02/08 , I have 4 cases that have a date added within that time , however two of these 13181 and 13190 have a record previously in the dataset outside the date range so I want to exclude these from the count as they arent new ids created in that range.

 

In the screenshot you can see my measure , however it seems to be affected by the slicer which is scewing the calculation.

 

My end goal would be something like this :

 

Calculate(distinctcount('IDS'[id]),Existed Previously = "No") 

 

so the count will only count cases that came in within the date range and it is the first time that they have existed in the whole dataset.

 

Anyone know where I am going wrong here ?

 

Thanks

 

 

2 REPLIES 2
Arranafc19
Helper IV
Helper IV

Hi @Anonymous 

 

This works but as soon as I create a relationship between the date table and the ids table it breaks

 

I basically need this to filter to pull back all ids within a chosen date range , and then check if there has ever been a record previously and if so I need to exclude.

 

On the example file you gave I would be expecting to see on the 01/08 , 4 distinct ids and of those 4 , 2 are new because the other two had a record previously outside of the date range. Need to just see totals for this .

 

Also , can the check be for just those with a value ? If there the id is blank I dont want it excluded if there were blanks previous 

 

 

Anonymous
Not applicable

Hi @Arranafc19 ,

 

Please try:

New IDs =
VAR MinDate =
    MIN ( 'Date'[Date] )
VAR MaxDate =
    MAX ( 'Date'[Date] )
RETURN
    IF (
        ISBLANK (
            CALCULATE (
                DISTINCTCOUNT ( 'IDS'[ID] ),
                FILTER (
                    'IDS',
                    'IDS'[Date Added] >= MinDate
                        && 'IDS'[Date Added] <= MaxDate
                        && CALCULATE ( COUNTROWS ( 'IDS' ), 'IDS'[Date Added] < MinDate ) = 0
                )
            )
        ),
        "No",
        "Yes"
    )

vcgaomsft_0-1691136084515.png

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

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.