Forum Discussion

AR_D's avatar
AR_D
Regular Visitor
1 year ago
Solved

dynamic x axis

Hi everyone

Below is the snapshot which right now i am getting 

 

When I am selecting "daily" then it's reflecting day wise, but when "Monthly i selected i want to only show month name on x axis not day-wise

In the slicer which i am using for "daily", "Monthly", "30-Day Moving Average so on, i have created a disconnected table then i have used the below dax for this 

Final PULP Trend =
VAR SelectedTrend = SELECTEDVALUE('Trend_Type'[Trend])
RETURN
    SWITCH(
        SelectedTrend,
        "Daily", [total pulp],
        "Monthly",
            CALCULATE(
                [total pulp],
                REMOVEFILTERS(Dim_Date[Date]),
                VALUES(Dim_Date[MonthYear])    
            ),
        "30-Day Moving Average",
            AVERAGEX(
                DATESINPERIOD(Dim_Date[Date], MAX(Dim_Date[Date]), -30, DAY),
                [total pulp]
            ),
        "90-Day Moving Average",
            AVERAGEX(
                DATESINPERIOD(Dim_Date[Date], MAX(Dim_Date[Date]), -90, DAY),
                [total pulp]
            ),
        [total pulp]
    )



Note : My focus is when i select Monthly then on x-axis it should show month name not date for each day.
How to achieve this.

Thanks in advance for the help or the guidence



 

 

  • AR_D's avatar
    AR_D
    1 year ago

    Ashish_Mathur FBergamaschi 
    Thanku so much for the reponse

    I came up with one solution and it working now.
    I am using two chart on chart for monthly and second one for the rest of the slicer.
    showing chart when monthly selected and hiding it if other are selected.

    Just used two measure for this and used visual lever filter.

    Once again thank you for the reply.

    Chart A Visibility =
    VAR _Trend = SELECTEDVALUE('Trend_Type'[Trend])
    RETURN
        IF(
            _Trend = "Monthly",
            0,
            1
        )


    Chart B Visibility =
    VAR _Trend = SELECTEDVALUE('Trend_Type'[Trend])
    RETURN
        IF(
            _Trend = "Monthly",
            1,
            0
        )

5 Replies

  • Hi AR_D 

    what is at the moment the role of the slicer you showed ?

     

    To answer your question:

    The only way to dinamically change the field in the x axis is to create a field parameter and include its column in the x axis of the line chart ajd select his value from the automatically added slicer

     

    But I want to understand what you are doing now so I can be sure I really answered you

     

    If this helped, please consider giving kudos and mark as a solution

    @me in replies or I'll lose your thread

    Want to check your DAX skills? Answer my biweekly DAX challenges on the kubisco Linkedin page

    Consider voting this Power BI idea

    Francesco Bergamaschi

    MBA, M.Eng, M.Econ, Professor of BI

     

     

    • AR_D's avatar
      AR_D
      Regular Visitor

      Thanku you the respose FBergamaschi 

      Let's suppose i want to show total sales ( total sales is on y-axis)
      and on x-axis what should i put

      so that it work for all the slicer
      like if i select daily then it should show daily datewise total sales 
      If monthly is selected then It should show total sales by month ( Note: on x-axis should show month name)

      Moving average and daily sales is working if on x-axis, i am putting date column
      but by focus is when i select monthly then it should show month wise means on x-axis instead of regular date it should show month name.


      • FBergamaschi's avatar
        FBergamaschi
        Super User

        I confirm you need a field parameter

         

        https://learn.microsoft.com/en-us/power-bi/create-reports/power-bi-field-parameters

         

         

        Please include, in a usable format, not an image, a small set of rows for each of the tables involved in your request and show the data model in a picture, so that we can import the tables in Power BI and reproduce the data model. The subset of rows you provide, even is just a subset of the original tables, must cover your issue or question completely. Do not include sensitive information and do not include anything that is unrelated to the issue or question. Please show the expected outcome based on the sample data you provided and make sure, in case you show a Power BI visual, to clarify the columns used in the grouping sections of the visual.

         

        Need help uploading data? click here

         

        Want faster answers? click here