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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Auto_queen
Helper I
Helper I

DAX Measure Changes When I add a field to my table visualization

I've tried a few different things and I'm stuck. I think it might have to do with how my tables are related, but not sure. 

 

I have this measure:  

TEST GP = IF(
[Total Credit] <> [Total Adjust Fee Amount],
[Collected GP],
SUM('Gross Profit'[TR1__GP_Amount__c]))
 
The values shown in the table are correct when the "Name" field is added to my table. But when I remove that field, it matches the Colelcted GP measure.  My goal is to show this measure monthly, but even when I add the month name to the table it also shows the 44K instead of the 42K. 
 
Auto_queen_0-1663689150522.pngAuto_queen_1-1663689245011.png

 

Here are my other measures:

 

Total Credit = SUMX(Collections, Collections[Credit]))
 
Total Adjust Fee Amount = SUMX('Closing Report', 'Closing Report'[TR1__Adjusted_Fee_Amount__c]))
 
Collected GP = 
IF(HASONEFILTER('Closing Report'[BH_ID__c]),[Total Credit] * [Closing Report Split],SUMX(VALUES('Closing Report'[BH_ID__c]),[Total Credit]*[Closing Report Split])))
 
 Closing Report Split = IF(HASONEFILTER(Collections[Num]),CALCULATE(SUMX('Gross Profit','Gross Profit'[Closing_Report_Split__c]),'Gross Profit'[TR1__GP_Amount__c] > 0),SUMX(VALUES(Collections[Num]),CALCULATE(SUMX('Gross Profit','Gross Profit'[Closing_Report_Split__c]),'Gross Profit'[TR1__GP_Amount__c] > 0)))
 
 
9 REPLIES 9
tamerj1
Super User
Super User

Hi @Auto_queen 

please try

TEST GP =
SUMX (
    VALUES ( 'Table'[Name] ),
    IF (
        [Total Credit] <> [Total Adjust Fee Amount],
        [Collected GP],
        CALCULATE ( SUM ( 'Gross Profit'[TR1__GP_Amount__c] ) )
    )
)

Sorry I should have said I tried that already and it did not work. It gave me a larger number 705917.60

@Auto_queen 

Check twice. Did you wrap SUM with CALCULATE?

Yes. 

TEST GP = SUMX(
    VALUES('Closing Report'[Name]),
     IF(
         [Total Credit] <> [Total Adjust Fee Amount],
[Collected GP],
CALCULATE(SUM('Gross Profit'[TR1__GP_Amount__c]))))
 
If I don't put CALCULATE before the SUM it is an even larger number. 
I think it might be how my tables are related... 

@Auto_queen 

How are they related?

Collections table > Invoice Table (Many to One) 

Collections is where I get the Total Credit measure. 

Invoice Table > Closing Report Table (Many to One)

Closing report table is where I get the Total Adjust Fee Amount measure. 

Gross Profit Table > Closing Report Table (Many to One)

Gross Profit table is where I get the closing report split measure and the total gp measure. 

 

They are all active relationships. 

@Auto_queen 
There is no issue with the model. The 'Closing Report' table is dimention table that is filtering other tables. I think the problem is somehow comming from the HASONEFILTER conditions in the sub-measures.

Actually, looking at my table again, I think the error is with my "Total Adjust Fee Amount" measure. 

 

When I have the "Name" column in the table that measure matches my total credit measure. When I take the "Name" column out the total adjust fee amount changes to 1,683,651. So, TEST GP formula is working because the total credit <> total adjust fee amount. 

 

I just tried this formula change but it didn't work. Any suggestions? I appreciate your help through this. 

Total Adjust Fee Amount =
SUMX(
VALUES('Closing Report'[Name]),
CALCULATE(
SUMX('Closing Report','Closing Report'[TR1__Adjusted_Fee_Amount__c])
)
)

 

Okay let me play around with those. I know there was a reason why I added that in there, but maybe the SUMX(VALUES)  is all I need... 

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

Check out the September 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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