Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago

Time Intelligence at Graph Interactions %MoM, %YoY

Hello to you all, come to ask for assistance.

Firstly, english isn't my mohter language, so i feel a bit confused if i'm being clear.

I'll try to give many details as possible.

 

I'm having some problems with time intlligence;

As it sees, I want to make the bar graph interactive with the
stampcards. As it shows in the pics.

Those are the dax formulas in use are

 

¹%Over90 MoM% = 
IF(
	ISFILTERED('PERFIL_RENEG'[DT_BASE]),
	ERROR("Medidas rápidas de inteligência de tempo somente podem ser agrupadas ou filtradas pela hierarquia de data fornecida pelo Power BI ou pela coluna de data primária."),
	VAR __PREV_MONTH = CALCULATE([¹%Over90], DATEADD('PERFIL_RENEG'[DT_BASE].[Date], -1, MONTH))
	RETURN
		DIVIDE([¹%Over90] - __PREV_MONTH, __PREV_MONTH)
)

 

¹%Over15-90 MoM% = 
IF(
	ISFILTERED('PERFIL_RENEG'[DT_BASE]),
	ERROR("Medidas rápidas de inteligência de tempo somente podem ser agrupadas ou filtradas pela hierarquia de data fornecida pelo Power BI ou pela coluna de data primária."),
	VAR __PREV_month = CALCULATE([¹%Over15-90], DATEADD('PERFIL_RENEG'[DT_BASE].[Date], -1, MONTH))
	RETURN
		DIVIDE([¹%Over15-90] - __PREV_month, __PREV_month)
)

 

¹AtvMoM = 
IF(
	ISFILTERED('PERFIL_RENEG'[DT_BASE]),
	ERROR("Medidas rápidas de inteligência de tempo somente podem ser agrupadas ou filtradas pela hierarquia de data fornecida pelo Power BI ou pela coluna de data primária."),
	VAR __PREV_MONTH =
		CALCULATE(
			SUM('PERFIL_RENEG'[Saldo Ativo]),
			DATEADD('PERFIL_RENEG'[DT_BASE].[Date], -1, MONTH)
		)
	RETURN
		DIVIDE(SUM('PERFIL_RENEG'[Saldo Ativo]) - __PREV_MONTH, __PREV_MONTH))
)

 

The reference table in use shows date by full, example: Thursday, November, 15, 2021.

4 Replies

  • v-chenwuz-msft's avatar
    v-chenwuz-msft
    Community Support

    Hi Anonymous ,

     

    The problem is the DATEADD(). When you select a month, the fact table imported to this page has been filtered only left the month you selected. the previous months have not been imported to the page. so there is no result.

     

    Maybe you can use some measures like the following when on the condition you have selected one month.

     

    VAR _s =
        SELECTEDVALUE( 'PERFIL_RENEG'[DT_BASE].[MonthNo] ) - 1
    VAR __PREV_MONTH =
        CALCULATE(
            SUM( 'PERFIL_RENEG'[Saldo Ativo] ),
            FILTER( ALL( 'PERFIL_RENEG' ), MONTH( [DT_BASE] ) = _s )
        )
    RETURN
    __PREV_MONTH
    when no selected, use your code is fine. combine these two conditions via if().
     

    Best Regards

    Community Support Team _ chenwu zhu

     

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

     

  • What is the error message when you select a single column?

     

    Be aware that your cards need to use a "Max(date)" filter otherwise the computation will spread across all bars - likely not what you want.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Oh, it shows those: (MdxScriptModel) (82, 2), (MdxScriptModel) (69, 2), (MdxScriptModel) (50, 2)

      • lbendlin's avatar
        lbendlin
        Super User

        oooh, fancy.  Not sure if that is a bug or caused by the way your data model is wired.  Could you potentially provide a sample pbix?