Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
8 years ago
Solved

Select a column by parameter

Hi everyone,   I am new to Power BI and exploring the dashboard. I have created a measure to calculate the cumulative value.   Cumulative Freezer= CALCULATE (     SUM ( 'Business Plan'[Freezer]...
  • Eric_Zhang's avatar
    Eric_Zhang
    8 years ago

    Anonymous wrote:

    Thanks for the disconnected slicer information. But I think the main difference is that I hope to filter by columns but the disconnected slicer filters data by rows. Still thanks for your information.


    Anonymous

    In my opinion, a better practice for your case is to unpivot the columns and slice the unpivoted column.

     

    If the way in your original post is still preferable, you could try to create measure as

     

    Cumulative Freezer =
    SWITCH (
        TRUE (),
        HASONEVALUE ( ParameterTable[Parameter] )
            && ISFILTERED ( ParameterTable[Parameter] )
            && LASTNONBLANK ( ParameterTable[Parameter], "" ) = "Freezer", CALCULATE (
            SUM ( 'Business Plan'[Freezer] ),
            FILTER (
                ALL ( 'Business Plan'[Period] ),
                'Business Plan'[Period] <= MAX ( 'Business Plan'[Period] )
            )
        ),
        HASONEVALUE ( ParameterTable[Parameter] )
            && ISFILTERED ( ParameterTable[Parameter] )
            && LASTNONBLANK ( ParameterTable[Parameter], "" ) = "Washing machine", CALCULATE (
            SUM ( 'Business Plan'[Washing machine] ),
            FILTER (
                ALL ( 'Business Plan'[Period] ),
                'Business Plan'[Period] <= MAX ( 'Business Plan'[Period] )
            )
        ),
        0
    )