Forum Discussion

rpiboy_1's avatar
rpiboy_1
Helper V
1 year ago

Understanding the differences between two time-intelligence expressions relative to Visual

I'm working on some time intliegence analysis. So I reviewed the Italian's article on the subject.

Prior to reviewing their article I had managed to write my own expression for YTD. I then applied their approach and also intergrated the hidden T/F Measure into my existing Measure. Both measures work fine in a Matrix, yet when I put both measures in a Card, only my original measure returns a value, the measure based on the DAX Pattern returns blank.

Is this due to the fact that my measure defines an explict date context, whereas the Pattern based measure relies on an explicit date context from the visual? In which case the Matrix meets that requirement, whereas the Card does not?

 

My original measure:

Closed RT YTD = 
VAR MaxDate = MAX('Date'[Date])
VAR MinDate = STARTOFYEAR('Date'[Date])

VAR _datesBetween = DATESBETWEEN('Date'[Date], MinDate, MaxDate)

VAR result = 
    IF(
        [ShowValueForProjectDates],
        CALCULATE(
            [Closed],        
            _datesBetween,
            ALL('Date')
        )
    )

RETURN
result

 DAX Pattern Measure:

Closed YTD = 
    
VAR _result =
    IF(
        [ShowValueForProjectDates],
        CALCULATE(
            [Closed],
            DATESYTD( 'Date'[Date] )
        )
    )

RETURN
    _result

Screen snip of cards vs matrix:

 

6 Replies

  • Deku's avatar
    Deku
    Super User

    It needs a date context. You can see the total is blank too.

     

    You should be able to supply a context by wrapping your calculate in another one, simulating the outer filter context that you get in a visual 

     

    Calculate(

       Your calculate

       , treatas( {max(dates[date])}, date[date])

    )

    • rpiboy_1's avatar
      rpiboy_1
      Helper V

      So my intution was correct, its the lack of date context supplied by the Card that causes the issue.

      My understanding was that it is generally bad form to nest Calculates within Calculates?

      My intution is that the biggest drawback to sticking with my original measure as compared to the DAX pattern based measure is likely performance, more than anything?

      • Deku's avatar
        Deku
        Super User

        Nothing wrong with nesting calculate, won't affect performance.

         

        The built in date intelligence functions are syntax sugar, you can achieve more versatililty and same performance with a custom one

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi rpiboy_1 

     

    Thanks Deku  for Addressing the issue.

     

    we would like to follow up to see if the solution provided by the super user resolved your issue. Please let us know if you need any further assistance.
    If our super user response resolved your issue, please mark it as "Accept as solution" and click "Yes" if you found it helpful.

     

    Regards,
    Vinay Pabbu

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi rpiboy_1,

       

      May I ask if you have gotten this issue resolved?

      If it is solved, please mark the helpful reply or share your solution and accept it as solution, it will be helpful for other members of the community who have similar problems as yours to solve it faster.

       

      Regards,
      Vinay Pabbu

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi rpiboy_1,

         

        May I ask if you have gotten this issue resolved?

        If it is solved, please mark the helpful reply or share your solution and accept it as solution, it will be helpful for other members of the community who have similar problems as yours to solve it faster.

         

        Regards,
        Vinay Pabbu