Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Smart Narrative Error: Couldn't Load Data for this Visual

Hello,

I am getting an error when using a Dax to pull the previous month name into smart narrative.

DAX
Last Month = CALCULATETABLE(VALUES('Date'[MonthInCalendar]),DATEADD('Date'[Date],-1,MONTH))

 

I am getting an error:

 

 
Dax works fine on a card:

 

 

 

  • Anonymous's avatar
    Anonymous
    5 years ago

    I needed a previous month as text in the format of Month Year like April 2021...

    I had a formula that was working using value in visuals but not in text box as a value.

    After trying a few formulas and researching and came up with this and it dynamic value no longer gives me an error that multiple results were given when a single value was expected:

     

    Last Month Alt =
    VAR test1 = LOOKUPVALUE('Date'[MonthInCalendar],'Date'[Date],DATEADD(ENDOFMONTH('Date'[Date]),-1,MONTH))
    Return
    test1
     
    Closing this post.

4 Replies

  • Anonymous ,

    This is going to create a table, are you trying this in a measure or table.

    • Anonymous's avatar
      Anonymous
      Not applicable

      amitchandak @I am trying this Dax in a measure so that I can use it in text box as a dynamic "value".

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

    Hi Anonymous ,

    Use the below measure:

    Last Month =
    VAR test1 =
        CALCULATE (
            VALUES ( 'Date1'[MonthInCalendar] ),
            FILTER (
                ALL ( date1 ),
                MAX ( date1[Date] ) = DATEADD ( date1[Date], 1, MONTH )
            )
        )
    RETURN
        IF ( test1 = BLANK (), 12, test1 )

     

     

    Wish it is helpful for you!

    Best Regards

    Lucien

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      I needed a previous month as text in the format of Month Year like April 2021...

      I had a formula that was working using value in visuals but not in text box as a value.

      After trying a few formulas and researching and came up with this and it dynamic value no longer gives me an error that multiple results were given when a single value was expected:

       

      Last Month Alt =
      VAR test1 = LOOKUPVALUE('Date'[MonthInCalendar],'Date'[Date],DATEADD(ENDOFMONTH('Date'[Date]),-1,MONTH))
      Return
      test1
       
      Closing this post.