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
Philandcas
Frequent Visitor

Help with measure to count where an event occured on a date

Hi experts,

I'm looking for some assistance in creating a measure that checks if one event or more occured on a particular date if it did then count as 1 ifelse 0.

I can easily count the total number of events that occur on a particular day but I'm stumped on how I create a measure to count only 1 where there may be many.

Amny help would be great.

Phil

 

1 ACCEPTED SOLUTION

Hi @Philandcas ,

You can create another measure as below to get it, please find the details in the attachment.

Number of dates which have events = SUMX(VALUES('Date'[Date]),[Measure])

yingyinr_0-1669862649048.png

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-yiruan-msft
Community Support
Community Support

Hi @Philandcas ,

You can create a measure as below to get it, please find the details in the attachment.

Measure = 
VAR _seldate =
    SELECTEDVALUE ( 'Date'[Date] )
VAR _count =
    CALCULATE (
        DISTINCTCOUNT ( 'Table'[Event] ),
        FILTER ( 'Table', 'Table'[Date] = _seldate )
    )
RETURN
    IF ( _count >= 1, 1, 0 )

yingyinr_0-1669800274953.png

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-yiruan-msft ,

Thank you for the reply, your calculation does exactly what I was hoping to do.
I do have one final question though, If I want to count the number days where there was an event how do I add that to the DAX?

What I need to be able to calculate is the number of dates where there was an event on, and the number dates where there wasn't an event on.

Kind regards

Phil

 

Hi @Philandcas ,

You can create another measure as below to get it, please find the details in the attachment.

Number of dates which have events = SUMX(VALUES('Date'[Date]),[Measure])

yingyinr_0-1669862649048.png

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
NikhilChenna
Continued Contributor
Continued Contributor

Hi @Philandcas ,

 

Consider this below example, 

Event    Date

A           11/29/2022

A           11/29/2022

B           11/29/2022

C           11/29/2022

So suppose if  condition is that on 29th Nov 22, A event should occur.

 

Then you have to create a calculated column in you table as ,

Calculated Column = IF('table1'[Date]="11/29/2022" && 'table1'[Event]="A",1,0)

 

So you'll get the output as below,

Event    Date                Eventsoccured

A           11/29/2022     1

A           11/29/2022     1

B           11/29/2022     0

C           11/29/2022     0

 

For getting the distinct count for this you have to use a calculated measure, 

Distinctcount =
CALCULATE(
DISTINCTCOUNT ('table1'[Eventsoccured]),
FILTER('table1','table1'[Eventsoccured]=1)
)

 

This will solve your issue.

 

Regards,

Nikhil Chenna

 

Appreciate with a Kudos!! (Click the Thumbs Up Button)
Did I answer your question? Mark my post as a solution!

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.

Top Solution Authors