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
jslade
Frequent Visitor

Removing Blank Row from Top N With Field Parameter

I'm using Field Parameters to allow a user to pick the column they want to see a top 5 in a Clusted Bar Chart.  
I created a RankX function with a SWITCH funciton that will allow me to filter the top 5, but it is including blanks in the Field Parameter.  How can I exclude the blank from the rankx function?  Below is my dax for the measure and a screenshot of what is happening

 

Stat Area Rank By Res = SWITCH(
TRUE(),
SELECTEDVALUE('Statistical Area'[Statistical Area Fields])="'DimCustomer'[CBSA]",
RANKX(ALLNOBLANKROW(DimCustomer[CBSA]), FactReservation[Reservations],,DESC),
SELECTEDVALUE('Statistical Area'[Statistical Area Fields])="'DimCustomer'[CSA]",
RANKX(ALLNOBLANKROW(DimCustomer[CSA]), FactReservation[Reservations],,DESC),
SELECTEDVALUE('Statistical Area'[Statistical Area Fields])="'DimCustomer'[MSA]",
RANKX(ALLNOBLANKROW(DimCustomer[MSA]), FactReservation[Reservations],,DESC))

 

jslade_3-1686332335105.png

 

I was able to filter the (blank) by adding adding a filter to the visual filters, but I'm afraid when the user changes the field parameter slicer it won't filter out based on the change.

 

 

 

2 REPLIES 2
jslade
Frequent Visitor

Thank you for these. I tried them both, but I am still getting the blank column in my bar charts.  The only way I have been able to filter it out is by adding each of the three DimCustomer fields (MSA, CBSA and CSA) to the visual filter and setting them to 'all except blank.'  This appears to work, but I fear that that if there is a result with MSA but CBSA is blank that it is just filtering that result out when MSA is selected in the field parameter slicer even though the MSA is not blank, because the visual is set to filter out blank CBSAs.

v-jingzhang
Community Support
Community Support

Hi @jslade 

 

You may try this 

Stat Area Rank By Res =
SWITCH (
    TRUE (),
    SELECTEDVALUE ( 'Statistical Area'[Statistical Area Fields] ) = "'DimCustomer'[CBSA]",
        RANKX (
            ALLNOBLANKROW ( DimCustomer[CBSA] ),
            CALCULATE (
                SUM ( FactReservation[Reservations] ),
                FactReservation[CBSA] <> BLANK ()
            ),
            ,
            DESC
        ),
    SELECTEDVALUE ( 'Statistical Area'[Statistical Area Fields] ) = "'DimCustomer'[CSA]",
        RANKX (
            ALLNOBLANKROW ( DimCustomer[CSA] ),
            CALCULATE (
                SUM ( FactReservation[Reservations] ),
                FactReservation[CSA] <> BLANK ()
            ),
            DESC
        ),
    SELECTEDVALUE ( 'Statistical Area'[Statistical Area Fields] ) = "'DimCustomer'[MSA]",
        RANKX (
            ALLNOBLANKROW ( DimCustomer[MSA] ),
            CALCULATE (
                SUM ( FactReservation[Reservations] ),
                FactReservation[MSA] <> BLANK ()
            ),
            DESC
        )
)

Or 

Stat Area Rank By Res =
SWITCH (
    TRUE (),
    SELECTEDVALUE ( 'Statistical Area'[Statistical Area Fields] ) = "'DimCustomer'[CBSA]",
        RANKX (
            FILTER ( ALL ( DimCustomer[CBSA] ), DimCustomer[CBSA] <> BLANK () ),
            FactReservation[Reservations],
            ,
            DESC
        ),
    SELECTEDVALUE ( 'Statistical Area'[Statistical Area Fields] ) = "'DimCustomer'[CSA]",
        RANKX (
            FILTER ( ALL ( DimCustomer[CSA] ), DimCustomer[CSA] <> BLANK () ),
            FactReservation[Reservations],
            ,
            DESC
        ),
    SELECTEDVALUE ( 'Statistical Area'[Statistical Area Fields] ) = "'DimCustomer'[MSA]",
        RANKX (
            FILTER ( ALL ( DimCustomer[MSA] ), DimCustomer[MSA] <> BLANK () ),
            FactReservation[Reservations],
            ,
            DESC
        )
)

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

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.