Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
8 years ago
Solved

Max Selected Month

I have to create a card to display just the selected month name.   My code below insn't working...any recommendations.

 

Requirements:

If no months are selected, then display blank.

If multiple months are selected, display the max month.

 

MaxSelectedMonth:=

var SelectedMonth = Format(max('Forecast Calendar'[Month]),"MMM")

return

 

If (ISBLANK(SelectedMonth),BLANK(),SelectedMonth)

 

 

 

  • Hi Anonymous,

     

    By my tests, you could modify your fomula like below.

     

    MaxSelectedMonth =
    VAR maxselected =
        CALCULATE (
            MAX ( 'Table1'[Month] )
        )
    RETURN
        IF ( ISFILTERED ( Table1[Month] ), maxselected )

    You may create another measure by SWITCH to show the Month Name.

     

    MaxSelectedMonth_ =
    SWITCH (
        [MaxSelectedMonth],
        1, "January",
        2, "February",
        3, "March",
        4, "April",
        5, "May",
        6, "June",
        7, "July",
        8, "August",
        9, "September",
        10, "October",
        11, "November",
        12, "December"
    )
    

    Then create a card visual with MaxSelectedMonth_ measure, you will get the output you expected.

     

     

     

    Hope this can help you!:smileywink:

     

    Best Regards,

    Cherry

  • Anonymous's avatar
    Anonymous
    8 years ago

    That did not work.  I get "Blank" when I click on a Month

     

    MaxSelectedMonth1 =
    VAR maxselected =
        CALCULATE (
            MAX ( 'Forecast Calendar'[Month])
        )
    RETURN
        IF ( ISFILTERED ( 'Forecast Calendar'[Month]), maxselected )

     

     

    SOLVED BY USING

     

    MaxSelectedMonth:= "Bookings " & LOOKUPVALUE(

     

    'Forecast Calendar'[Month Year],

    'Forecast Calendar'[Relative Month Index],

    [MaxSelectedRelativeMonth]

    )

     

     

     

4 Replies

  • Zubair_Muhammad's avatar
    Zubair_Muhammad
    Community Champion

    hi Anonymous

     

    Try this revision

     

    MaxSelectedMonth =
    VAR SelectedMonth =
        FORMAT ( MAX ( 'Forecast Calendar'[Month] ), "MMM" )
    RETURN
        IF ( ISFILTERED ( 'Forecast Calendar'[Month] ), SelectedMonth )
    • Sirhawk3017's avatar
      Sirhawk3017
      Helper II

      I got a blank on this one as well on the card visual.

  • v-piga-msft's avatar
    v-piga-msft
    Resident Rockstar

    Hi Anonymous,

     

    By my tests, you could modify your fomula like below.

     

    MaxSelectedMonth =
    VAR maxselected =
        CALCULATE (
            MAX ( 'Table1'[Month] )
        )
    RETURN
        IF ( ISFILTERED ( Table1[Month] ), maxselected )

    You may create another measure by SWITCH to show the Month Name.

     

    MaxSelectedMonth_ =
    SWITCH (
        [MaxSelectedMonth],
        1, "January",
        2, "February",
        3, "March",
        4, "April",
        5, "May",
        6, "June",
        7, "July",
        8, "August",
        9, "September",
        10, "October",
        11, "November",
        12, "December"
    )
    

    Then create a card visual with MaxSelectedMonth_ measure, you will get the output you expected.

     

     

     

    Hope this can help you!:smileywink:

     

    Best Regards,

    Cherry

    • Anonymous's avatar
      Anonymous
      Not applicable

      That did not work.  I get "Blank" when I click on a Month

       

      MaxSelectedMonth1 =
      VAR maxselected =
          CALCULATE (
              MAX ( 'Forecast Calendar'[Month])
          )
      RETURN
          IF ( ISFILTERED ( 'Forecast Calendar'[Month]), maxselected )

       

       

      SOLVED BY USING

       

      MaxSelectedMonth:= "Bookings " & LOOKUPVALUE(

       

      'Forecast Calendar'[Month Year],

      'Forecast Calendar'[Relative Month Index],

      [MaxSelectedRelativeMonth]

      )