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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
vazmor
Helper II
Helper II

Rank hyrachy with previus column

Hello, I ask for your help in order to do the following: I have a Matrix as the attachment I need to get the rank based on a brand level but the ranking is from the store. (The attached file is the final result I want to obtain)

 

File-Example

 

Rank  = 
VAR IsCountryFiltred =
    ISFILTERED ( Catalogo_Reporte_Diario[Customer_Name] )
VAR IsTitleSeasonFiltered =
    ISFILTERED ( Catalogo_Reporte_Diario[Grand_Brand])
VAR IsTitleSeason =
    HASONEVALUE ( Catalogo_Reporte_Diario[Grand_Brand] )
RETURN
    IF (
        ISBLANK ( [Amount] ),
        BLANK (),
        IF (
            IsCountryFiltred && IsTitleSeasonFiltered,
            RANKX ( ALL ( Catalogo_Reporte_Diario[Customer_Name] ),  [Amount],, DESC, SKIP ),
            IF (
                IsTitleSeasonFiltered && NOT IsCountryFiltred,
                RANKX ( ALL ( Catalogo_Reporte_Diario[Retailer_Name] ), CALCULATE (  [Amount] ) ),
                BLANK ()
            )
        )
    )
1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @vazmor ,

 

Try to add the following column to your table:

 

Rank  = 
 CALCULATE(
                COUNTROWS(Catalogo_Reporte_Diario);
                FILTER(
                    ALL(Catalogo_Reporte_Diario);
                     Catalogo_Reporte_Diario[Grand_Brand] = EARLIER(Catalogo_Reporte_Diario[Grand_Brand]) &&
                    Catalogo_Reporte_Diario[AMOUNT] < EARLIER(Catalogo_Reporte_Diario[AMOUNT])
                    )
                    )+1

If you prefer to use a measure try the following:

Rank = 

 CALCULATE(
                COUNTROWS(Catalogo_Reporte_Diario);
                FILTER(
                    ALL(Catalogo_Reporte_Diario);
                     Catalogo_Reporte_Diario[Grand_Brand] = SELECTEDVALUE(Catalogo_Reporte_Diario[Grand_Brand]) &&
                    Catalogo_Reporte_Diario[AMOUNT] < SELECTEDVALUE(Catalogo_Reporte_Diario[AMOUNT])
                    )
                    )+1

Regards,

MFelix


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

1 REPLY 1
MFelix
Super User
Super User

Hi @vazmor ,

 

Try to add the following column to your table:

 

Rank  = 
 CALCULATE(
                COUNTROWS(Catalogo_Reporte_Diario);
                FILTER(
                    ALL(Catalogo_Reporte_Diario);
                     Catalogo_Reporte_Diario[Grand_Brand] = EARLIER(Catalogo_Reporte_Diario[Grand_Brand]) &&
                    Catalogo_Reporte_Diario[AMOUNT] < EARLIER(Catalogo_Reporte_Diario[AMOUNT])
                    )
                    )+1

If you prefer to use a measure try the following:

Rank = 

 CALCULATE(
                COUNTROWS(Catalogo_Reporte_Diario);
                FILTER(
                    ALL(Catalogo_Reporte_Diario);
                     Catalogo_Reporte_Diario[Grand_Brand] = SELECTEDVALUE(Catalogo_Reporte_Diario[Grand_Brand]) &&
                    Catalogo_Reporte_Diario[AMOUNT] < SELECTEDVALUE(Catalogo_Reporte_Diario[AMOUNT])
                    )
                    )+1

Regards,

MFelix


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.