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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Michiel123
New Member

Allow external filtering in measure

Hi,

 

I'm facing the following problem:

 

I have a table that contains a list of error messages, including the start and end date of that error. I want to create a graph that show me how many errors were active on each date (so where the date is between the start and end date of the error). The X-axis on the graph is based on a separate date table.

 

Based on some other topics here, I have created the following measure, which works perfectly. However, each error also has a specific error category. With the current measure, it is not possible to filter based on each category. Would anyone be able to provide me with some advice?

 

Measure: 

Error active between 2 dates? = COUNTAX(FILTER(ALL('Errors'), Errors[Start Date]<=MAX('Date Table'[Date])&&Errors[End Date)]>=MAX('Errors'[Date])), Errors[Error ID])
1 ACCEPTED SOLUTION
daXtreme
Solution Sage
Solution Sage

Hint: Claiming that a measure "works perfectly" is a very risky statement in the world of DAX. It's better to refrain from such statements.

 

// Please note that 'Date Table' should not have
// any relationship defined with the Errors table.
// Otherwise, this will not work.

[Active Error Count] =
var SelectedDate = SELECTEDVALUE( 'Date Table'[Date] )
var ErrorActiveCount =
    // Assuming that Errors stores in each row
    // a separate error that is identified with
    // ErrorID and Start/End Date fields are not
    // blank. If this is not true, the logic must
    // be adjusted.
    CALCULATE(    
        COUNTROWS( Errors ),
        KEEPFILTERS(
            Errors[Start Date] <= SelectedDate
            &&
            SelectedDate <= Errors[End Date]
        )
    )
return
    ErrorActiveCount

 

 

 

 

View solution in original post

1 REPLY 1
daXtreme
Solution Sage
Solution Sage

Hint: Claiming that a measure "works perfectly" is a very risky statement in the world of DAX. It's better to refrain from such statements.

 

// Please note that 'Date Table' should not have
// any relationship defined with the Errors table.
// Otherwise, this will not work.

[Active Error Count] =
var SelectedDate = SELECTEDVALUE( 'Date Table'[Date] )
var ErrorActiveCount =
    // Assuming that Errors stores in each row
    // a separate error that is identified with
    // ErrorID and Start/End Date fields are not
    // blank. If this is not true, the logic must
    // be adjusted.
    CALCULATE(    
        COUNTROWS( Errors ),
        KEEPFILTERS(
            Errors[Start Date] <= SelectedDate
            &&
            SelectedDate <= Errors[End Date]
        )
    )
return
    ErrorActiveCount

 

 

 

 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.