Forum Discussion

josedecima's avatar
josedecima
New Member
2 years ago
Solved

Fecha de maximo valor filtrado en tabla.

Hola, como estan? en este ejemplo quisiera saber la fecha del maximo valor. En el ejemplo que muestro sabemos que el maximo valor de DE LA CRUZ CRISTINA EVELYN es 27 de la fecha 30/04/2024 y la otra 47 de la fecha 20/05/2024. Solo estas fechas de los valores maximos alcanzados deberian aparecerme por mes. Me ayudan con esto?

 

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi, josedecima 

    Based on your description, I created the following sample data:

    As you described, the expected result is to take out the maximum value for each month for each name. I created a measure using the following DAX expression:

    MEASURE =
    VAR _table =
        SUMMARIZE (
            ALL ( 'Table' ),
            'Table'[date],
            'Table'[name],
            'Table'[amount],
            "month", MONTH ( 'Table'[date] )
        )
    VAR _table1 =
        ADDCOLUMNS (
            _table,
            "maxValue",
                VAR _month = [month]
                VAR _name = 'Table'[name]
                RETURN
                    MAXX (
                        FILTER ( _table, 'Table'[name] = _name && [month] = _month ),
                        'Table'[amount]
                    )
        )
    VAR _table2 =
        ADDCOLUMNS (
            _table1,
            "maxDay",
                VAR _month = [month]
                VAR _name = 'Table'[name]
                VAR _maxValue = [maxValue]
                RETURN
                    MAXX (
                        FILTER (
                            _table1,
                            'Table'[name] = _name
                                && [month] = _month
                                && [maxValue] = _maxValue
                        ),
                        'Table'[date]
                    )
        )
    RETURN
        IF (
            SELECTEDVALUE ( 'Table'[date] )
                = MAXX (
                    FILTER (
                        _table2,
                        'Table'[name] = SELECTEDVALUE ( 'Table'[name] )
                            && [month] = MONTH ( SELECTEDVALUE ( 'Table'[date] ) )
                    ),
                    [maxDay]
                ),
            1,
            0
        )

    Put this metric on the filter of the table visual and set it to one:

    You can put the first part of this DAX expression in a DAX query to see how it works:

    I've provided the PBIX file used this time below.

     

     

    How to Get Your Question Answered Quickly

    If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

    Best Regards

    Jianpeng Li

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

     

1 Reply

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi, josedecima 

    Based on your description, I created the following sample data:

    As you described, the expected result is to take out the maximum value for each month for each name. I created a measure using the following DAX expression:

    MEASURE =
    VAR _table =
        SUMMARIZE (
            ALL ( 'Table' ),
            'Table'[date],
            'Table'[name],
            'Table'[amount],
            "month", MONTH ( 'Table'[date] )
        )
    VAR _table1 =
        ADDCOLUMNS (
            _table,
            "maxValue",
                VAR _month = [month]
                VAR _name = 'Table'[name]
                RETURN
                    MAXX (
                        FILTER ( _table, 'Table'[name] = _name && [month] = _month ),
                        'Table'[amount]
                    )
        )
    VAR _table2 =
        ADDCOLUMNS (
            _table1,
            "maxDay",
                VAR _month = [month]
                VAR _name = 'Table'[name]
                VAR _maxValue = [maxValue]
                RETURN
                    MAXX (
                        FILTER (
                            _table1,
                            'Table'[name] = _name
                                && [month] = _month
                                && [maxValue] = _maxValue
                        ),
                        'Table'[date]
                    )
        )
    RETURN
        IF (
            SELECTEDVALUE ( 'Table'[date] )
                = MAXX (
                    FILTER (
                        _table2,
                        'Table'[name] = SELECTEDVALUE ( 'Table'[name] )
                            && [month] = MONTH ( SELECTEDVALUE ( 'Table'[date] ) )
                    ),
                    [maxDay]
                ),
            1,
            0
        )

    Put this metric on the filter of the table visual and set it to one:

    You can put the first part of this DAX expression in a DAX query to see how it works:

    I've provided the PBIX file used this time below.

     

     

    How to Get Your Question Answered Quickly

    If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

    Best Regards

    Jianpeng Li

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