cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mpatel181
Helper II
Helper II

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)

 

 

 

2 ACCEPTED SOLUTIONS
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @mpatel181,

 

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.

 

 

Capture.PNG

 

Hope this can help you!Smiley Wink

 

Best Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

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]

)

 

 

 

View solution in original post

3 REPLIES 3
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @mpatel181,

 

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.

 

 

Capture.PNG

 

Hope this can help you!Smiley Wink

 

Best Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

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]

)

 

 

 

View solution in original post

Zubair_Muhammad
Community Champion
Community Champion

hi @mpatel181

 

Try this revision

 

MaxSelectedMonth =
VAR SelectedMonth =
    FORMAT ( MAX ( 'Forecast Calendar'[Month] ), "MMM" )
RETURN
    IF ( ISFILTERED ( 'Forecast Calendar'[Month] ), SelectedMonth )

Regards
Zubair

Please try my custom visuals

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

November Power BI Update 768x460.png

Check it Out!

Click here to read more about the November 2021 Updates!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.