Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Days calculating error

Hi. 

 

I'm trying to make a calculation based on the difference between two dates (two days), but the result is not the one that is expected (in red), but shows as "infinite". 

It seems to me that the interval between days (Interval Days measure) despite being shown correctly on the card (30 days) for the calculation is considering as zero, so the result as "infinite". :smileyfrustrated:

 

Could someone help me by pointing out a way to solve this error ? 

 

Greetings !

 

  • Hi Anonymous

     

    Try this for your measure, placing it in the values of a matrix with Month and Day on rows as you show. Table1 is the table containing Month and Day columns shown in the matrix visual.

     

     

    Calc Target =
    SELECTEDVALUE ( Table1[Day] )
        * DIVIDE (
            CALCULATE ( COUNT ( Table1[Day] ) - 1, ALL ( Table1[Day] ) ),
            [BaseValue]
        )

     

    Code formatted with  

11 Replies

  • AlB's avatar
    AlB
    Community Champion

    Hi Anonymous

     

    Try this for your measure, placing it in the values of a matrix with Month and Day on rows as you show. Table1 is the table containing Month and Day columns shown in the matrix visual.

     

     

    Calc Target =
    SELECTEDVALUE ( Table1[Day] )
        * DIVIDE (
            CALCULATE ( COUNT ( Table1[Day] ) - 1, ALL ( Table1[Day] ) ),
            [BaseValue]
        )

     

    Code formatted with  

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi AlB

       

      Thank you for the help so fast. :smileyvery-happy:

      Could you tell me why the code I have posted did not work? Just to understand the reason ... 

       

      Tks

      • AlB's avatar
        AlB
        Community Champion

        Anonymous

        :smileyhappy: You're welcome.

        I could, if you share the pbix. Otherwise we'd have to spend too much time while I ask about details omitted in your explanation.

        In any case, my current guess would be as follows:

        Fact: the division yields infinite,

        so [Interval Days] must be zero,

        which means [Initial Day] = [Last Day],

        which implies that MIN(dCalendario[Data]) = MAX(dCalendario[Data]),

        from which we can deduce that the day number for dCalendario[Data] has a sole distinct value in the filter context when the measure is evaluated.

         

        You have Month and Day in the rows of your visual. That defines a sole day number value in dCalendario[Data].