Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Changing display text when multiple values are selected

This measure makes it so I am able to select more than one month on my report.    When no months are selected, however, it returns this.    Is it possible to make the card display "All ...
  • Anonymous's avatar
    Anonymous
    7 years ago

    Anonymous wrote:

    This measure makes it so I am able to select more than one month on my report. 

     

    When no months are selected, however, it returns this. 

     

    Is it possible to make the card display "All Months?" 

     

    I would greatly appreciate any advice. 


    Well, first of all, you should not use the automatically generated table of dates in Power BI (you should disable this option). Please do yourself a favour and create a proper date table and connect it to your fact table. If you want to have problems down the line and not know how to deal with them, you can use the automatic table but don't say I have not warned you!

     

    Once you have the date table in the model connected to your fact table, you can do this:

     

    [Months Visible] =
    var __numberOfVisibleMonths =
    	DISTINCTCOUNT( Dates[MonthShortName] )
    var __allMonthsSelected =
    	__numberOfVisibleMonths = 12
    var __monthsVisible =
    	CONCATENATEX(
    		SUMMARIZE(
    			Dates,
    			Dates[MonthShortName],
    			Dates[MonthNumberInTheYear]
    		),
    		Dates[MonthShortName],
    		", ",
    		Dates[MonthNumberInTheYear]
    	)
    return
    	if( __allMonthsSelected,
    		"All Months",
    		__monthsVisible
    	)

     

    Your model does not look to be correctly structured. Please learn a bit about the correct design and the star schema. You'll save yourself grief and scratching your head.

     

    Best

    Darek