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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
stefanjt
Frequent Visitor

Sorting Blank Values from Fact Table

Dear Community,

 

I need your help with something that may seem simple but I've been struggling with for a while, even after doing some research, trial and error.

 

I have a dimension table connected to a fact table. Not all entries from the dimension table are present in the fact table. I'm showing a table visual with a few columns coming from the dimension table and a whole number column coming from the fact table. For those entries from the dimension table that are missing from the fact table, the whole number column from the fact table comes out as blank. How do I ensure that sorting by the whole number column will always show the blank values in the end, regardless of the sorting order (ascending or descending)? I need to show the rows from the dimension table that have no corresponding entries in the fact table.

 

Thank you in advance!

1 ACCEPTED SOLUTION

Hi, @Anonymous and thanks for the suggestion. It has pointed me toward the solution that works for me.

 

The original requirement was to display dimension table entries without corresponding scores in the fact table, in the bottom of the table visual regardless of the sorting order, instead of in the middle as it was before. I've achieved showing them at the end when sorting DESC, in the following way:

 

  1. I've added a column in PowerQuery with the sorting order:stefanjt_0-1732264717253.png
  2. I've sorted the Score group by the new column:stefanjt_2-1732264792942.png

     

The result is this: 

stefanjt_3-1732264823742.png

I guess this is the best that can be done at the moment. Report: https://www.dropbox.com/scl/fi/tuaslajaw737hccyhtwzk/Sorting-Blanks-Demo-Report.pbix?rlkey=cfjdy6566bh6w69g1oybn1kgh&dl=0 

 

Thanks all for your help!

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hi @stefanjt 

 

Thank you very much Sahir_Maharaj for your prompt reply.

 

May I ask if your problem has been solved? If not, let me share something with you.

 

Due to the default design of power bi desktop, it sorts all data in visual as a whole. So your desire to keep null values out of the sort may be difficult to achieve. But I can provide you some other ways.

 

Create a measure.

 

SortOrder = 
var _blank = IF(
    NOT(ISBLANK(SUM('FactScore'[Score]))),
    1, 
    BLANK()
)
var _rank = 
RANKX(
    ALL('FactScore'),
    CALCULATE(SUM('FactScore'[Score])),
    ,
    ASC,
    Dense
)
RETURN
IF(
    _blank = 1,
    _rank,
    BLANK()
)

 

You can get:

 

vnuocmsft_0-1732178658614.png

 

This way, you can keep null values from being inserted into non-null values by ascending or descending the [SortOrder] column.

 

vnuocmsft_1-1732178814225.png

 

This approach accomplishes as much as possible for your purposes.

 

Regards,

Nono Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi, @Anonymous and thanks for the suggestion. It has pointed me toward the solution that works for me.

 

The original requirement was to display dimension table entries without corresponding scores in the fact table, in the bottom of the table visual regardless of the sorting order, instead of in the middle as it was before. I've achieved showing them at the end when sorting DESC, in the following way:

 

  1. I've added a column in PowerQuery with the sorting order:stefanjt_0-1732264717253.png
  2. I've sorted the Score group by the new column:stefanjt_2-1732264792942.png

     

The result is this: 

stefanjt_3-1732264823742.png

I guess this is the best that can be done at the moment. Report: https://www.dropbox.com/scl/fi/tuaslajaw737hccyhtwzk/Sorting-Blanks-Demo-Report.pbix?rlkey=cfjdy6566bh6w69g1oybn1kgh&dl=0 

 

Thanks all for your help!

Anonymous
Not applicable

Hi @stefanjt 

 

Thank you very much for sharing! You can accept it as a solution, which helps to help others discover the problem!

 

Regards,

Nono Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

stefanjt
Frequent Visitor

Hi, @Sahir_Maharaj and thanks for taking the time to provide some suggestions.

 

Unfortunately, I'm unable to implement them as I do not have a sort column from the dimension table. I'm referring to the standard sorting capability when you click on a heading of a table visual.

 

I am attaching a sample report - https://www.dropbox.com/scl/fi/rce0wv2bndqo96pddsrsq/Sorting-Blanks-Demo-Report.pbix?rlkey=etzblw6ze....

 

The requirement is to show the rows from the dimension table that do not have matches from the fact table but always at the bottom, regardless of the sorting order. At the moment they show in the middle:

stefanjt_0-1731583587097.pngstefanjt_1-1731583589400.png

 

Sahir_Maharaj
Super User
Super User

Hello @stefanjt,

 

Can you please try this approach:

Sorted Value = 
IF(
    ISBLANK('FactTable'[WholeNumberColumn]),
    IF(SELECTEDVALUE('DimensionTable'[Sort Order]) = "Ascending", 9999999, -9999999),
    'FactTable'[WholeNumberColumn]
)

Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution? (Yes, its FREE!)
➤ Lets connect on LinkedIn: Join my network of 15K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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