Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

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 @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.

 

 

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

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]

)

 

 

 

View solution in original post

3 REPLIES 3
v-piga-msft
Resident Rockstar
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.

 

 

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.
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]

)

 

 

 

Zubair_Muhammad
Community Champion
Community Champion

hi @Anonymous

 

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.