Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago

More than 1 Rankx

Please see attached data.

Attached screenshot is this report in Excel and the end result I am looking for.

 

First, sort service detail descending then pick the bottom 20

Second, sort service group descending and then pick top 20

 

For Service Detail - I created a measure using the following DAX

Rank_SvcDtl =

IF (

ISINSCOPE('Table' [Service Detail]),

RANKX(

ALLSELECTED('Table' [Service Detail]),

CALCULATE(SUM('Table' [Gross Revenue]),

FILTER(ALL('Table' [Gross Revenue]),'Table' [Gross Revenue]<>BLANK())),,ASC,Dense))

I pulled this measure and filtered on less than 21. Here was the problem. 

Not all items were showing 20. Some only showed 19.  So if I increased my filter number then my Gross Revenue was off for some Groups.

 

For Service Group - I created the following measure

Rank_SvcGrpRk2 =

IF(

ISINSCOPE('Table' [Service Group]),

RANKX(

ALLSELECTED('Table' [Service Group]),

CALCULATE(SUM('Table' [Gross Revenue]),

FILTER(ALL('Table' [Gross Revenue]),

Table' [Gross Revenue]<>BLANK())),,DESC,Dense))

Same problem as Service Detail.  The total Gross Revenue was off.

I tried using SKIP instead of DENSE.  That didn’t help.

I know I am on the right path.  I have to create Rank measures, and then filter or maybe for one of them I need to use TOP N.

I am just not able to narrow down on what is causing the issue.

I have been at this for a few days.  Hope someone can shed some light on this.

Also - if I were to add the Clinics and just get Top 10 - would that again be a new measure.

 

THANK YOU for looking into this.

ClinicsService GroupService DetailGross Revenue
Clinic 152 - ChemotherapyDetail Ch$3,419k
Clinic 152 - ChemotherapyDetail RT ($1k)
Clinic 132 - Grouper DDetail E$420k
Clinic 132 - Grouper DDetail PPS$397k
Clinic 132 - Grouper DDetail F$320k
Clinic 132 - Grouper DFoot$201k
Clinic 132 - Grouper DSports Medicine$114k
Clinic 154 - Infusion TherapyDetail InT$919k
Clinic 154 - Infusion TherapyDetail Ch$201k
Clinic 153 - Radiation TherapyDetail RT$114k
Clinic 119 - PacemakerDetail E$919k
Clinic 254 - Infusion TherapyDetail P$45k
Clinic 254 - Infusion TherapyDetail V$19k
Clinic 254 - Infusion TherapyMiscellaneous Services ($1k)
Clinic 254 - Infusion TherapyDetail Ch ($20k)
Clinic 253 - Radiation TherapyDetail RT$871k
Clinic 219 - PacemakerDetail E$613k
Clinic 256 - HyperbaricWound Care$428k
Clinic 276 - Lab and PathologyDetail O$187k
Clinic 276 - Lab and PathologyDetail EM$9k
Clinic 276 - Lab and PathologyDetail TM$3k
Clinic 276 - Lab and PathologyDetail V$2k
Clinic 276 - Lab and PathologyDetail HM$1k
Clinic 276 - Lab and PathologyPSA Test$1k
Clinic 276 - Lab and PathologyChemistry$0k
Clinic 276 - Lab and PathologyDetail U$0k
Clinic 352 - ChemotherapyDetail Ungrp ($0k)
Clinic 352 - ChemotherapyDetail RT ($1k)
Clinic 332 - Grouper DDetail E$420k
Clinic 332 - Grouper DDetail PPS$397k
Clinic 332 - Grouper DDetail F$320k
Clinic 332 - Grouper DFoot$201k
Clinic 332 - Grouper DSports Medicine$114k
Clinic 477 - All Other OPDetail I$919k
Clinic 477 - All Other OPDetail EM$45k
Clinic 477 - All Other OPDetail Ungrp$19k
Clinic 477 - All Other OPDetail InT ($1k)
Clinic 473 - Other Diagnostic RadiologyMedical Cardiology ($1k)
Clinic 419 - PacemakerDetail E$613k
Clinic 456 - HyperbaricWound Care$428k
Clinic 532 - Grouper DDetail F$320k
Clinic 532 - Grouper DFoot$201k
Clinic 532 - Grouper DSports Medicine$114k
Clinic 554 - Infusion TherapyDetail InT$919k
Clinic 554 - Infusion TherapyDetail P$45k
Clinic 554 - Infusion TherapyDetail V$19k
Clinic 554 - Infusion TherapyMiscellaneous Services ($1k)
Clinic 577 - All Other OPDetail I$919k
Clinic 577 - All Other OPDetail EM$45k
Clinic 577 - All Other OPDetail Ungrp$19k
Clinic 577 - All Other OPDetail InT ($1k)

12 Replies

  • Add a tiny random value (thousandths of cents) to your values to break the ties.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Thank you lbendlin 

    Any suggestions on - why not all 20 are showing.  Some DETAIL and also SERVICE GROUP show only 19.

      • Anonymous's avatar
        Anonymous
        Not applicable

        lbendlin  Hi

        I tried - but keep erroring out.  Here is my Rank measure.  Not sure where I would add RAND()

        Rank_SvcDtl =

        IF (

            ISINSCOPE(‘TABLE’[SVC_DTL]),

            RANKX(

                ALL(‘TABLE’[SVC_DTL]),     

                CALCULATE(SUM(‘TABLE’[Gross Rev Var]),

                    FILTER(ALL(‘TABLE’[Gross Rev Var]),’TABLE’[Gross Rev Var]<>BLANK())),,DESC,Dense))