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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Count Duplicates Within a Range of Values

Hello,

Looking for a solution to my issue currently I am trying to have a duplicate count to display when a room is occupied within a duration of time 

Example I want rooms that are the same that have the same room on the same day within the same time range to be counted as a duplicate not just when its start and end time are the same.

Power BI Question.png

Thanks in advance for any help n this subject

7 REPLIES 7
Anonymous
Not applicable

bump.

@Anonymous

 

Try this calculated column

 

Duplicate Test =
VAR CurrentStart = TableName[Date/Start Time Required]
VAR CurrentEnd = TableName[Date/End Time Required]
RETURN
    CALCULATE (
        COUNTROWS ( TableName ),
        FILTER (
            ALLEXCEPT ( TableName, TableName[Room (Option 1)], TableName[Date Rqeuired] ),
            OR (
                TableName[Date/Start Time Required] > CurrentStart
                    && TableName[Date/Start Time Required] < CurrentEnd,
                TableName[Date/End Time Required] > CurrentStart
                    && TableName[Date/End Time Required] < CurrentEnd
            )
        )
    )

Regards
Zubair

Please try my custom visuals
Anonymous
Not applicable

@Zubair_Muhammad
I'm not the most familiar with DAX but that returned this warning
A single value for column 'Date/Start-Time Required' in table 'Overlapping' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result.

@Anonymous

 

You tried adding it as a MEASURE....

 

The formula I wrote was for a calculated colum

There is an option to add Column as well...Please use that OPTION


Regards
Zubair

Please try my custom visuals
Anonymous
Not applicable

@Zubair_Muhammad

Thank you for the help with this, I am very new to power BI, but seem to still have an issue with this calculable column it is complaining about a 'Token Eof Expected' on VAR CurrentStart
My code currently looks like this:

Duplicate Test 
=
VAR CurrentStart = Overlapping[#"Date/Start-Time Required"]
VAR CurrentEnd = Overlapping[#"Date/End-Time Required"]
RETURN
    CALCULATE (
        COUNTROWS ( Overlapping),
        FILTER (
            ALLEXCEPT ( Overlapping, Overlapping[#"Room (Option 1)"], Overlapping[Date Required] ),
            OR (
                Overlapping[#"Date/Start-Time Required"] > CurrentStart
                    && Overlapping[#"Date/Start-Time Required"] < CurrentEnd,
                Overlapping[#"Date/End-Time Required"] > CurrentStart
                    && Overlapping[#"Date/End-Time Required"] < CurrentEnd
            )
        )
    )




Hi Chris

Please share your file
I will look into it after few hours and get back to you

Regards
Zubair

Please try my custom visuals
Anonymous
Not applicable

I can't share files in post but I have dropped it here...
https://www.dropbox.com/home?preview=Overlapping.pbix

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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