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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Dominok123
Frequent Visitor

Return True depending on Date Frequency of Groups

Hey,

 

So I'm trying to figure out how to create the third column 'Infrequent' as seen in the table below. What I need this column to return is whether or not the same ID has had multiple records but 6+ months apart. If the records are 6+ months apart, the Infrequent column would return 1, otherwise 0. However, as you can see with ID #3 in the below table, one record is actually 6+months apart from the other rows, however this also would be 0 as the other two records are not 6months apart. I only want to identify ID's that have never had two records within 6 months of each other.

 

Any help would be much appreciated.

 

Table1:

IDDateInfrequent
101/01/20190
103/02/20190
216/01/20181
220/10/20181
317/03/20180
302/06/20180
331/03/20190
405/06/20171
401/03/20191

 

2 REPLIES 2
AlB
Community Champion
Community Champion

Hi @Dominok123 

Try this for your new calculated column, where Table1 is the table you show:

NewColumn =
VAR _AuxTable =
    ADDCOLUMNS (
        CALCULATETABLE ( DISTINCT ( Table1[Date] ); ALLEXCEPT ( Table1; Table1[ID] ) );
        "_Dif";
        VAR _PreviousDate =
            CALCULATE ( MAX ( Table1[Date] ); Table1[Date] < EARLIER ( Table1[Date] ) )
        RETURN
            IF (
                NOT ISBLANK ( _PreviousDate )
                    && DATEDIFF ( _PreviousDate; [Date]; MONTH ) <= 6;
                1;
                0
            )
    )
RETURN
    IF ( SUMX ( _AuxTable; [_Dif] ) = 0; 1; 0 )

See it at work in the attached file

@AlB Thats a pretty good start, appreciate the effort!

 

Testing it out on my real dataset its picking up ID's which have multiple instances of the same date. So ID #30 with two rows of Date: 30/07/2018 is placed as '1'. It also allocates '1' to every row that only has 1 ID. So if theres only one row with ID #60 then that is placed as '1'.

 

My bad, should have made better dummy data to account for these things.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.