Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
felipereis50
Frequent Visitor

RANKX with MAXX - KPI Information

Hi friends
I would like some help.
I have a fTable with some product revenue values, return values, transfer...etc and I made a rankx to show de best selling product.

(using top N)

felipereis50_0-1690371479519.png
And I'm using an external filter on table
Read "1-Faturamento Saídas" like Revenue

felipereis50_1-1690371582024.png

--------------------off topic------------
If I don't use external filter the values will be for all table, and I need only revenue

felipereis50_5-1690372024525.png

 

 

 

 

RankX_Vendas =
VAR vRank = RANKX(ALL(fDados[DESCRICAO (#1)]),[TopN_Vendas_v6],,DESC)
RETURN
IF(
    vRank <= 'TopN(Parameter)'[TopNvalor] && ISINSCOPE(fDados[DESCRICAO (#1)]),
    vRank ,
    BLANK())


TopN_Vendas_v7 =
CALCULATE(
        [#vlr_contabil],
            KEEPFILTERS(TOPN('TopN(Parameter)'[TopNvalor],ALL(fDados[DESCRICAO (#1)]),[#vlr_contabil])))



Now, I want to show in another column with the MAXx, the  value for the first item  and so on, until TOPN
Then I created another measure
In this measure I'm forcing the filter inside the formula intead external filter.

MAXX_teste =
MAXX(fDados,
CALCULATE(
        [#vlr_unit_item],
            FILTER(dCFOPeFaturamento,dCFOPeFaturamento[EVOLUÇÃO TRIBUTOS CFOP] = "1 - Faturamento Saídas"))
      )


The result is values is corretc, but, when a put the measure on the table, the Dax expand for all products

felipereis50_3-1690371951189.png


-----------check value - rank number 1 --------------

felipereis50_7-1690372235019.png

 

 

What I have to do to not expand the table? 



1 ACCEPTED SOLUTION
felipereis50
Frequent Visitor

Myself find a way. I Have use an IF on formula.


MAXX_teste =
var ma_ = MAXX(fDados,
        CALCULATE(
                [#vlr_unit_item],
                    FILTER(dCFOPeFaturamento,dCFOPeFaturamento[EVOLUÇÃO TRIBUTOS CFOP] = "1 - Faturamento Saídas"))
                    )
RETURN
IF([TopN_Vendas_v7] = BLANK(), BLANK(), ma_)

felipereis50_0-1690373210443.png

 




View solution in original post

1 REPLY 1
felipereis50
Frequent Visitor

Myself find a way. I Have use an IF on formula.


MAXX_teste =
var ma_ = MAXX(fDados,
        CALCULATE(
                [#vlr_unit_item],
                    FILTER(dCFOPeFaturamento,dCFOPeFaturamento[EVOLUÇÃO TRIBUTOS CFOP] = "1 - Faturamento Saídas"))
                    )
RETURN
IF([TopN_Vendas_v7] = BLANK(), BLANK(), ma_)

felipereis50_0-1690373210443.png

 




Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors