Forum Discussion

dofrancis3's avatar
dofrancis3
Icon for Resolver I rankResolver I
2 years ago
Solved

Pourcentage and latest date

Hello Guys!

Please i need your help

I would like to calculate and display the vaccination percentage for only the latest date for each count

Below exemple of my data

 

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi dofrancis3 ,
    Thanks for the new data, here are my changes to the second MEASURE:

    Percentage = 
    CALCULATE(
        MAX('Table'[Number of vaccinated]),
        FILTER(
            'Table',
            SELECTEDVALUE('Table'[Date of vaccination]) = [LastDate]
        )
    )

    Final output

     

    Best regards,

    Albert He

     

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

5 Replies

  • Do you want to do that in DAX or in Power Query?

     

     

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi dofrancis3 ,
    Here some steps that I want to share, you can check them if they suitable for your requirement.
    Here is my test data:

    Create two dax

    LastDate = 
    CALCULATE(
        MAX('Table'[Date of vaccination]),
        ALLEXCEPT(
            'Table',
            'Table'[Country]
        )
    )
    Percentage = 
    VAR _number = 
    CALCULATE(
        MAX('Table'[Number of vaccinated]),
        FILTER(
            'Table',
            SELECTEDVALUE('Table'[Date of vaccination]) = [LastDate]
        )
    )
    VAR SumByCountry = 
    CALCULATE(
        SUM('Table'[Number of vaccinated]),
        ALLEXCEPT(
            'Table',
            'Table'[Country]
        )
    )
    RETURN
    _number / SumByCountry

    Final output

    Best regards,

    Albert He

     

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

     

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi dofrancis3 ,
    Thanks for the new data, here are my changes to the second MEASURE:

    Percentage = 
    CALCULATE(
        MAX('Table'[Number of vaccinated]),
        FILTER(
            'Table',
            SELECTEDVALUE('Table'[Date of vaccination]) = [LastDate]
        )
    )

    Final output

     

    Best regards,

    Albert He

     

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