Forum Discussion

char23's avatar
char23
Icon for Helper II rankHelper II
2 years ago
Solved

Create count column visual based on column slicer and column group on x-axis

I am trying to write a measure to create a dynamic visual. I have the following table below as a single table in my file. I want the user to be able to select a month. If the user selects June. Then ...
  • lbendlin's avatar
    2 years ago

    You cannot do all this with only one table.  You need to create a disconnected table for the month slicer, and then use a measure as the filter for your original table visual.

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi char23 

     

    Thank you very much lbendlin for your prompt reply. The solution you offer is reasonable. Let me add some details here.

     

    Create a new month table.

    Date = 
    DISTINCT(
        SELECTCOLUMNS(
            'Table',
            "Month",
            'Table'[Month].[Month]
        )
    )

     

     

    Create a measure.

     

    Measure = 
    var _selectMonth = SELECTEDVALUE('Date'[Month])
    var _DateRank = 
    CALCULATE(
        SELECTEDVALUE('Table'[Date Rank]),
        FILTER(
            ALL('Table'),
            'Table'[Month].[Month] = _selectMonth
        )
    ) + 1
    var _tablecalculation = 
    CALCULATE(
        COUNTROWS('Table'),
        FILTER(
            ALL('Table'),
            'Table'[Date Rank] = _DateRank
            && 
            'Table'[Status] = "Not Normal"
            && 
            'Table'[Previous Status] = "Not Normal"
            && 
            'Table'[Type] = "Task"
        )
    )
    RETURN _tablecalculation

     

    Here is the result.

     

    Regards,

    Nono Chen

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.