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

Perfect Days Flag

Hi 

 

I'm new to DAX and have followed a number of guides which have got me started but I'm struggling to get something to work and would appreciate some help please!

 

I have an 'Event' table and a 'Calendar' table and want to produce a graph that shows by month the days when a specific event happened vs days when it didn't. If the event didn't happen, we call it a 'Perfect Day'. 

 

I have created the following measures :

 

No. of Events = CALCULATE COUNTROWS (Event) , Event [Did specific event occur?] = "Yes" )
 
Perfect Day =IF ( [No. of Events] > 0 , "No" , "Yes" )
 
This works in a table/graph with Calendar[Date] in, but unfortunately when I want to display this summarised by month, it is based on the event happening accross the month, and I want to keep the context at days and display something like this with one colour for 'Perfect' and one for 'Not Perfect':
 
Yarters_0-1675956710736.png

 

 

I think I am missing something, possibly very obvious but can't seem to work it out!

 

Thanks in advance

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

Try

Num perfect days =
VAR SummaryTable =
    ADDCOLUMNS ( VALUES ( 'Calendar'[Date] ), "@num days", [No. of events] )
VAR Result =
    COUNTROWS ( FILTER ( SummaryTable, [@num days] = 0 ) )
RETURN
    Result

View solution in original post

2 REPLIES 2
Yarters
Frequent Visitor

Thanks, that gives me a count - and if I create another measure like this I can stack the 2 measures in a stacked bar - thanks for your help!

Num Imperfect Days =
COUNTROWS('Calendar') - [Num perfect days]
johnt75
Super User
Super User

Try

Num perfect days =
VAR SummaryTable =
    ADDCOLUMNS ( VALUES ( 'Calendar'[Date] ), "@num days", [No. of events] )
VAR Result =
    COUNTROWS ( FILTER ( SummaryTable, [@num days] = 0 ) )
RETURN
    Result

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