0

I have a data table that captures information on events, using three key columns to identify events by their "Incident Date", "Incident Name", and "Space Name". Using dax in Power BI, I want to count the number of distinct "Incident Names" in a defined date range.

I've tried to do this using the following dax query:

MonthX Unique Events= CALCULATE(DISTINCT('Incident Tracker'[Incident Name]),DATESBETWEEN('Incident Tracker' [Incident Date],01/01/24,01/10/24))

However, Power BI will not let me use DATESBETWEEN as the data table is not a date table.

Attempting to convert the table to a date table fails because there are days when a single incident affects multiple different spaces, leading to multiple different entries in the table under the same date. Another reason is that multiple incidents can sometimes occur on the same date.

Incident Date Incident Name Space Name
01/01/24 Snowball fight Mess hall
01/01/24 Snowball fight Lounge
01/01/24 Blizzard Garden
01/10/24 Ice storm Lounge
01/10/24 Ice storm Mess hall
01/10/24 Ice storm Lounge

The number of unique incidents from 01/01/24 - 01/10/24 would be 3 in this case^.

Any advice for how to get the count of unique incidents using a dax query?

1
  • did you try to convert it to date ? date( year (right ('Incident Tracker' [Incident Date],2), month ( mid ( 'Incident Tracker' [Incident Date], 4,2) , left ( 'Incident Tracker' [Incident Date],2)) Commented Aug 10 at 12:24

1 Answer 1

0
MonthX Unique Events= CALCULATE(DISTINCTCOUNT ('Incident Tracker'[Incident Name]),'Incident Tracker'[Incident Date] >= DATE(2024,1,1) && 'Incident Tracker'[Incident Date] <= DATE(2024,10,1))

If you have a separate date table and a slicer on it (to make it more dynamic) i would consider using a many to one relationship using just DistinctCount and no calculate

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.