Forum Discussion

Pbiuserr's avatar
Pbiuserr
Post Prodigy
4 years ago
Solved

Syntax issue with TOPN argument TABLE

Hello.
I have a measure which retrive name of category which has max [Change] value. I'd like to add another dimension to that - not only category, but also a gender and filter it to be female. so for instance out of gender (female), category 2 has max value, so output should be: category2

TOP cat name =
VAR _top_name = FIRSTNONBLANK(TOPN(1,VALUES(FctTable[Category]),[Change]),1)
RETURN
_top_name

it gives me name associated with max value when it concerns only one dimension - category. I'd like to add filter context of gender and only females Tried to ADDCOLUMNS inside TOPN but it didnt work.

Perhaps it should have other approach? Any ideas and tips are welcome
  • I've resolved my problem by using formula

     

    CALCULATE( MAX(FctTable[Category]), TOPN(1, FILTER( SUMMARIZE (FctTable, FctTable[Gender], FctTable[Category], "@Chng", [Change]), FctTable[Gender] = "Female"), ABS([Change])) )

3 Replies

  • Pbiuserr , Not very clear, check if one of the two can help

     

    calculate(max(FctTable[Category]) ,TOPN(1,allselected(FctTable[Category]),[Change]), values(FctTable[Category]))

     

    or

     

    calculate([Change] ,TOPN(1,allselected(FctTable[Category]),[Change]), values(FctTable[Category]))

    • Pbiuserr's avatar
      Pbiuserr
      Post Prodigy

      Hi Amit
      I'd like to create such table virtually and retrive "Category" with max value for gender = "Female". "Change" is a measure, not column if it helps

      • Pbiuserr's avatar
        Pbiuserr
        Post Prodigy

        I've resolved my problem by using formula

         

        CALCULATE( MAX(FctTable[Category]), TOPN(1, FILTER( SUMMARIZE (FctTable, FctTable[Gender], FctTable[Category], "@Chng", [Change]), FctTable[Gender] = "Female"), ABS([Change])) )