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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
RogerSteinberg
Post Patron
Post Patron

Perform a rank based on a measure combining multiple tables

Hi,

 

I would like to products based on measure that computes over two columns from two different tables.

I have 4 tables:

Table 1: Product Names

Table 2: Dates

Table 3: Cost 

Table 4: Revenue 

I have one measure:

Profit to Revenue: 
DIVIDE(
SUMX(Revenue,Revenue)-SUMX(cost,Cost),

SUMX(Revenue,Revenue)

)

 

I have two fact tables (cost, revenue) both related to the product name and date tables as a many:1 relationships

 

I'd like to rank my products in a descending order by total cost after having filtered that table by profit margin > 0.50.

 

Current Table looks like this : 

Product (Product Name Table)Cost (Cost Table)Revenue (Revenue Table)Profit To Revenue (Measure)
A $                 10.00 $                                 20.00 $                                          0.50
B $                   5.00 $                                 15.00 $                                          0.67
C $                 10.00 $                                 50.00 $                                          0.80

 

Desired Output: As you can see the rank is based on the cost column after having filtered out products that had 0.50 and lower Profit to revenue value.

Product (Product Name Table)Cost (Cost Table)Revenue (Revenue Table)Profit To Revenue (Measure)Rank 
B $                   5.00 $                                 15.00 $                                          0.672
C $                 10.00 $                                 50.00 $                                          0.801

 

One import thing to consider is that I have a date slicer that always selects a date range. So that rank needs to be applied on the aggregate values for that period . Same goes to the filter of 0.50 which should be applied on the date range as well.

6 REPLIES 6

Hi, thanks for the documentation but the issue i'm having doesn't lie in making a simple rank function, it is when trying to filter a table prior to ranking when my main measure involves two tables that are indirectly connected.

v-deddai1-msft
Community Support
Community Support

Hi @RogerSteinberg ,

 

You may need a measure like:

 

 

 

RANK =
IF (
    ISFILTERED ( [Profit To Revenue] ),
    RANKX (
        FILTER ( ALL ( 'Product Name'[Product] ), [Profit To Revenue] > 0.5 ),
        CALCULATE ( SUM ( 'Cost'[Cost] ) )
    ),
    RANKX ( ALL ( 'Product Name'[Product] ), CALCULATE ( SUM ( 'Cost'[Cost] ) ) )
)

 

 

 

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

 

Best Regards,

Dedmon Dai

 

You cant pass the measure in the first expression of ISFILTERED.
Plus having the ALL would rank my entire dataset even if I have a date slicer of my chosen period which defeats the purpose.

Hi @RogerSteinberg ,

 

The reason why I added measure to the isfiltered function is because I think you added [Profit To Revenue] to the visual level filter for filtering. This works very well in the sample I created myself. In addition, I use the all (column) just cleared the filter on this column, if you have other slicers you can use allselected (column) instead.

 

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

 

Best Regards,

Dedmon Dai

No what I mean is that the measure that I created Profit to Revenue can't be passed in the ISFILTERED function.

I believe it can only accept a Column

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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