Forum Discussion

docdata's avatar
docdata
Frequent Visitor
1 year ago
Solved

Tooltip with RANKX over years

A table visual with a Country, Announcements, Investment, and Jobs columns has a custom tooltip.  In the tooltip, I'm trying to plot a country's rank (jobs and investment) over time.   Here are var...
  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi,docdata .Thank you for your reply.
    It looks like you have successfully implemented the first step of giving the rankx the correct computational environment (computational table range), you now need to modify the filters in your MEASUREMENT according to your actual sorting needs.
    I have looked at your two ways of writing the sort and here is my analysis of the results of their implementation:
    Your first Use the ALLEXCEPT writeup:

     ALLEXCEPT(
          MergedOppsAnns,
          MergedOppsAnns[new_announcement.1.new_date].[Year]
        )
    

    ALLEXCEPT function: removes all filters except year.
    CALCULATE function: calculates the total number of jobs for each country in a given year
    RANKX function: the total number of jobs calculated in descending order, using dense ranking

    In short, your current computing environment has only a year as a filter, and not any other filter (the ranking results will only be affected by changes in the relevant year field)

    Your second writeup using SUMMARIZECOLUMNS

    generates a summary table, and I notice that you are not using any filters, similar to using the ALL() function directly.
    You can try adding more filters to your table constraints. For example, if you only want to see data for a specific country.

    like this:

    EVALUATE
      SUMMARIZECOLUMNS(
        MergedOppsAnns[new_internationalcountyname],
        MergedOppsAnns[new_announcement.1.new_date].[Year],
        FILTER(
          MergedOppsAnns,
          MergedOppsAnns[new_internationalcountyname] = "Specific Country"
        ),
        "Jobs", CALCULATE(SUM(MergedOppsAnns[new_announcement.1.new_jobs])),
        "Country Jobs Rank", 'MergedOppsAnns'[Country Jobs Rank],
        "Investment", CALCULATE(SUM(MergedOppsAnns[new_announcement.1.new_investments])),
        "Investment Rank", [Country Investment Rank]
      )

    You can add other filter functions to it to make it dynamically sorted

    If you want the ranking to target specific countries or other dimensions, you can adjust the ALLEXCEPT function in RANKX. For example, keep the country and year filters:

     countryYear_Rankx=
     RANKX(
        ALLEXCEPT(
          MergedOppsAnns,
          MergedOppsAnns[new_announcement.1.new_date].[Year],
          MergedOppsAnns[new_internationalcountyname]
        ),
        CALCULATE(SUM(MergedOppsAnns[new_announcement.1.new_jobs])),
        ,
        DESC,
        Dense
    )

    Most importantly, you need to double-check the usage of the functions you use to make sure they meet your real needs and get the right sorting results!
    You can check the following links to see more filtering dax functions
    URL:

    Filter functions (DAX) - DAX | Microsoft Learn

    SUMMARIZE function (DAX) - DAX | Microsoft Learn


    I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
    Best Regards,
    Carson Jian,
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.