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
Anonymous
Not applicable

How to see if ID is in previous month when all months are in one table

Below is my data, the second column is the unique idenfier I am trying to create a formula each month to say new/existing. If it was in previous month it is existing if it wasn't its new. I have tried so many ways and just can't get it. Right now I only have Feb/Mar data loaded. Thanks in advance.

 

 

anicholls_0-1617041268944.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

You can create a measure as below:

New/Existing =
VAR _curperiod =
    SELECTEDVALUE ( 'SBU'[Report Period] )
VAR _curid =
    SELECTEDVALUE ( 'SBU'[ID] )
VAR _count =
    CALCULATE (
        COUNT ( 'SBU'[ID] ),
        FILTER (
            ALL ( 'SBU' ),
            'SBU'[ID] = _curid
                && 'SBU'[Report Period] <= _curperiod
        )
    )
RETURN
    IF ( _count > 1, "Existing", "New" )

yingyinr_0-1617258126146.png

If the above one is not working for your scenario, please provide your expected result with sample or screenshot. Thank you.

Best Regards

View solution in original post

7 REPLIES 7
Anonymous
Not applicable

Hi @Anonymous ,

You can create a measure as below:

New/Existing =
VAR _curperiod =
    SELECTEDVALUE ( 'SBU'[Report Period] )
VAR _curid =
    SELECTEDVALUE ( 'SBU'[ID] )
VAR _count =
    CALCULATE (
        COUNT ( 'SBU'[ID] ),
        FILTER (
            ALL ( 'SBU' ),
            'SBU'[ID] = _curid
                && 'SBU'[Report Period] <= _curperiod
        )
    )
RETURN
    IF ( _count > 1, "Existing", "New" )

yingyinr_0-1617258126146.png

If the above one is not working for your scenario, please provide your expected result with sample or screenshot. Thank you.

Best Regards

I get this to work in a measure. Can it be created in a column?

Anonymous
Not applicable

Hello, all data is in one table?

Hi, @Anonymous 

Do you have custom-date-table ?



Microsoft MVP



If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.




LinkedInVisit my LinkedIn page




Outlook BookingSchedule a short Teams meeting to discuss your question



Anonymous
Not applicable

Yes, I have a standardard date table

Hi, @Anonymous 

Then you can create one measure as I mentioned above.

All data come from the date table, and your main table.

 



Microsoft MVP



If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.




LinkedInVisit my LinkedIn page




Outlook BookingSchedule a short Teams meeting to discuss your question



Jihwan_Kim
Super User
Super User

Hi, @Anonymous 

Please correct me if I wrongly understand your question.

 

Inside your measure, please try to define the below by using VAR.

 

first table: VALUES(customersID-culumn)  as current month customer, and 

second table: calculatetable (VALUES(customersID-culumn), filter(alldatestable, monthnumber = maxmonthnumber-1)) as previous month customer.

 

intersect (first table, second table) = existing customers table

except (first table, second table) = new customer table

 

Hi, My name is Jihwan Kim.

If this post helps, then please consider accept it as the solution to help other members find it faster.

 



Microsoft MVP



If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.




LinkedInVisit my LinkedIn page




Outlook BookingSchedule a short Teams meeting to discuss your question



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.