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 m...
  • v-piga-msft's avatar
    8 years ago

    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]

    )