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

Incorrect Total from Measure Incorrect

Hi, I'm new to DAX and PowerBI.  I have a fairly simple measure but cannot seem to get it to work.  Any help would be appreciated!

I am working in a live data model so I am limited to creating measures.  I have the following measure:

Active =
VAR TotalSpare = CALCULATE(SUM('table'[QuantityValue]), 'table'[Type] = 1 ||'table'[Type] = 3 
RETURN
IF([Recommended]<= TotalSpare, [Recommended], TotalSpare)
 
"Recommended" is another measure.  I cannot get the correct total, even though the line totals are correct.  At one point I added SUMX function prior to the IF statement, but got the same result.  
 2020-01-20_21-19-38.png
1 ACCEPTED SOLUTION
JustJan
Responsive Resident
Responsive Resident

Hi @MDMC ,

 

The grand totals line is not calculated from the table above, but is recalculated at the grand total line. So the filter conditions for the measure calculation are different in that case. 

 

Try something like this: 

 

=IF(HASONEVALUE(Table[Category])
,[Active]
,SUMX(SUMMARIZE(VALUES(Table[Category]),Table[Category],"NumberOfActives",[Active]),[NumberOfActives])
)

 

basically it tells the measure to use your [Active] measure when one line level and when on the grand total line Summarize the values of [Active]. I referred to the first blurred column as Table[Category].

 

Hope this helps.

 

Jan 

if this is a solution for you, don't forget to mark it as such. thanks

 

View solution in original post

3 REPLIES 3
JustJan
Responsive Resident
Responsive Resident

Hi @MDMC ,

 

The grand totals line is not calculated from the table above, but is recalculated at the grand total line. So the filter conditions for the measure calculation are different in that case. 

 

Try something like this: 

 

=IF(HASONEVALUE(Table[Category])
,[Active]
,SUMX(SUMMARIZE(VALUES(Table[Category]),Table[Category],"NumberOfActives",[Active]),[NumberOfActives])
)

 

basically it tells the measure to use your [Active] measure when one line level and when on the grand total line Summarize the values of [Active]. I referred to the first blurred column as Table[Category].

 

Hope this helps.

 

Jan 

if this is a solution for you, don't forget to mark it as such. thanks

 

MDMC
Frequent Visitor

That worked!  Thank you so much!

Mishutka
Frequent Visitor

Well, I am getting close.  The dax formula I have now is

=var Assister = MAX(Table1[Salesperson])
var MinDate = min(Table1[Date])
var MaxDate = max(Table1[Date])
return
if(HASONEFILTER(Table1[Salesperson]),

CALCULATE(SUM(Table1[Sales value]),all(Table1[Salesperson]),Table1[SalesAssist]=Assister,

Table1[Date]>=MinDate,Table1[Date]<=MaxDate),

CALCULATE(SUM(Table1[Sales value]),Table1[Date]>=MinDate,Table1[Date]<=MaxDate)

)

 

And this is almost right. The pivot table looks like this:

Annotation 2020-06-22 150634.jpg

 

As you can see, the data for 8/1/20 shows 107 for Sales for Lawrie, and for Total but the Assister shows no sales for anyone, but a total of 107. This should be for John, but because he has no sales for the day, his assists dont show up. This is from the data table:

Date      Customer     Sales value    Salesperson         Sales Assist

07-JanAcme Subs100JohnJane
07-JanWidgets Inc75JohnLawrie
07-JanAcme Subs125JaneJohn
07-JanWidgets Inc175LawrieJohn
08-JanWidgets Inc107LawrieJohn

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