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
Anonymous
Not applicable

Comparing a totaled value with a related field in another table

Objective: I want to summarize daily detailed data by month and then compare the totaled results to a value in a related record in a dimension table -- and then based on the comparison filter out certain results.  To state this more clearly, I want to summarize Gross Profit from by daily detailed table by Customer and then compare the summed Gross Profit to a GP Threshold value stored in a Customers dimension table, and lastly filter out those Total Gross Profit that are greater than the customer's GP Threshold.  I would like to accomplish the above without having to create a summarized table in PowerQuery/M as my data set is very large and takes a very long time to load.  Instead I would prefer to only load the detail data and then accomplish the above through DAX formulas.

 

Problem: I can visually get the summed totals in a Matrix or a Table visual and also side by side display the dimension value from the related dimension table.  I can do this whether putting the direct fields from the detailed table into the visual, or by creating measures the SUMX the fields. However, I can not figure out how to do the comparison (the IF) and then the filtering.

 

Example data is below.

 

Any suggestions on how to approach this without summarizing first in PowerQuery?

 

Thanks,

Example Tables:

Dimensions -

Customer Table

Cust NoCust
AABC
BBCD
CCDE
DDEF

 

Thresholds 

Cust NoGP Threshold
A10
C30

 

Date Reference

DateYearMonthOfYearMonth Name
1/1/202020201January
1/2/202020201January
1/3/202020201January
2/1/202020202February
2/15/202020202February
3/1/202020203March
3/2/202020203March
3/3/202020203March
3/4/202020203March
3/5/202020203March
3/16/202020203March
4/1/202020204April
4/2/202020204April
4/3/202020204April
4/4/202020204April
4/5/202020204April
4/15/202020204April
4/16/202020204April

 

Transactions-

Daily Transactions

Cust NoDateRevGross Profit
A1/1/202010011
A1/2/20201008
A2/1/20201009
A2/15/202010013
A3/1/202010012
A4/2/20201004
B1/3/202020018
C3/3/202030035
C3/4/202030026
C4/5/202030025
D3/16/202040042
D4/15/202040043
D4/16/202040035

 

Table output

PBI Community 1.png

 

Matrix Output

PBI Community 2.png

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Thanks Miguel!

 

Yes this did work for both comparing a GP target as well as, with a few modifications, a GP percentage target.

 

I am still coming up to speed with when to use Calculate and the Context perspectives.  I'll study through this and tyr to figure out why your solution worked.

 

On thing that confused me was the need to Sum the values in the GP Threshold dimension table when there is only a single matching row (one:many relationship) instead of just being able to simply reference that single row/value.  If you have a simple explanation or insight that may help me.

 

I'll mark this as solved.

 

Thanks,

View solution in original post

2 REPLIES 2
MFelix
Super User
Super User

Hi @Anonymous ,

 

I have prepared a mockup file, however I have some doubts about what is the result you need.

 

To what I can understand you want to show gross profit for values below the treshold correct?

 

On the file attach I have created the following measure:

Measure_tofilter_gross_profit =
IF (
    CALCULATE (
        SUM ( 'Thresholds'[GP Threshold] );
        FILTER (
            ALL ( 'Thresholds'[GP Threshold] );
            'Thresholds'[GP Threshold] = SELECTEDVALUE ( 'Thresholds'[GP Threshold] )
        )
    )
        - SUM ( 'Daily Transactions'[Gross Profit] ) < 0;
    1;
    BLANK ()
)

Basically if the GP Threshold is greater or equal to the sum ogf the gross profit I return 1 otherwise is blank.

 

Can you check if this is correct. if this is correct and based on this you want to make the gross profit blank based on this comparision please tell me and we can adjust the calculations.

 

Another question is regarding regarding the totals you only want to show the sum of the ones that are visible?


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



Anonymous
Not applicable

Thanks Miguel!

 

Yes this did work for both comparing a GP target as well as, with a few modifications, a GP percentage target.

 

I am still coming up to speed with when to use Calculate and the Context perspectives.  I'll study through this and tyr to figure out why your solution worked.

 

On thing that confused me was the need to Sum the values in the GP Threshold dimension table when there is only a single matching row (one:many relationship) instead of just being able to simply reference that single row/value.  If you have a simple explanation or insight that may help me.

 

I'll mark this as solved.

 

Thanks,

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.