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 Months?" 

 

I would greatly appreciate any advice. 

  • 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

3 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    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

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you for the advice! I have read a bit about the star schema- I am not sure if it would work with the data I am using. It was pulled from a company ERP system and the data is essentially stacked on top of one another. I performed joins in SQL Server and transferred the file to Power BI as a single table, per my supervisor's request.

      • Anonymous's avatar
        Anonymous
        Not applicable

        Whoever your supervisor is... he's got little idea about proper dimensional design :)

         

        You want to know better? Go to www.sqlbi.com and read all you can read in there... Find the right articles on proper design within Power BI. Tell your supervisor as well to do the same since he has no idea what he says to you and what problems you'll have down the line with a single table design.

         

        Best

        Darek