I am struggling with a "simple" function that is killing me. I am simply trying to get the subtotal of each group in a pivot table. I d like to compute the percentage of each subgroup as my input data are wrong. It seems I cannot do the classic EARLIER, and there is no this or current or whatever...
CALCULATE (
SUM ( table1[numbers] ),
FILTER (
ALL ( table1 ),
table1[Names] = FIRSTNONBLANK ( ALL ( table1[Names] ), tables[Names] )
)
)
Thanks
Found it! Absolutely counterintuitive to me, but it works...
=CALCULATE (
SUM ( table1[numbers] ),
ALLEXCEPT ( table1, table1[Names])
)
Related
The following DAX formula works on Power BI but not on Power Pivot (don't show error but blank cells) using the same exact data model (checked this many times).
It's used in a calculated column.
Actual Units SO =
CALCULATE (
SUM ( COM_SellOut[QuantitySold] ),
FILTER ( COM_SellOut, COM_SellOut[Date] >= TMK_Promotion[FromDate] ),
FILTER ( COM_SellOut, COM_SellOut[Date] <= TMK_Promotion[ToDate] ),
FILTER ( COM_SellOut, COM_SellOut[ProductCode] = TMK_Promotion[ProductCode] ),
FILTER ( COM_Customers, COM_Customers[id] = TMK_Promotion[Customer] )
)
A little context: this formula iterates a promotion table and calculates the units sold of a given product, in a given customer between a given period. Works flawlessly in PowerBI but not on PowerPivot.
Any ideas of what could be causing the problem?
Thanks in advance!
Power Pivot and Power BI use the same engine, so the same version DAX works in both applications. Are you using a colon (Actual Units SO :=) in front of your equal sign (no space). In Power Pivot it's a must whereas in Power BI it's optional. I see in your example there is no colon, so your DAX measure won't work in Power Pivot. It's a syntax issue not a model or DAX issue.
Actual Units SO :=
CALCULATE (
SUM ( COM_SellOut[QuantitySold] ),
FILTER ( COM_SellOut, COM_SellOut[Date] >= TMK_Promotion[FromDate] ),
FILTER ( COM_SellOut, COM_SellOut[Date] <= TMK_Promotion[ToDate] ),
FILTER ( COM_SellOut, COM_SellOut[ProductCode] = TMK_Promotion[ProductCode] ),
FILTER ( COM_Customers, COM_Customers[id] = TMK_Promotion[Customer] )
)
I think you can get a better performance by using logical and in one filter rather than nesting your filters :
Actual Units SO =
CALCULATE (
SUM ( COM_SellOut[QuantitySold] ),
FILTER ( COM_SellOut, COM_SellOut[Date] >= TMK_Promotion[FromDate]
&& COM_SellOut, COM_SellOut[Date] <= TMK_Promotion[ToDate]
&& COM_SellOut, COM_SellOut[ProductCode] = TMK_Promotion[ProductCode]
&& COM_Customers, COM_Customers[id] = TMK_Promotion[Customer]
)
)
Good day to everyone, I am having a problem where I am creating a measure in Power Pivot Excel where the goal is to create a Accuracy Percentage based upon the division of 2 columns. Please see the attached picture below.
As you can see, dividing by 0 gives a 100 percent accuracy when it reality it should be blank and or not counted. The formula i am using for this percentage calculation is listed below.
=
IF (
ISBLANK (
1 - DIVIDE (
( DISTINCTCOUNT ( '03a Qry for Inaccurate Count'[KEY] ) ),
( DISTINCTCOUNT ( Std_MainData[KEY] ) )
)
),
0,
1 - DIVIDE (
( DISTINCTCOUNT ( '03a Qry for Inaccurate Count'[KEY] ) ),
( DISTINCTCOUNT ( Std_MainData[KEY] ) )
)
)
Please let me know if this is possible to fix, thanks.
I'm trying to create a measure that re-calculates the rank in the power pivot table everytime the user deselects a value or changes the group by row labels. For example, per table below, there are 3 companies rates per quote id with their respective rank in each quote.
Is there a measure that can recalulcate the rank of each company's rate per quote id if the user deselects company B so that power pivot table would look like this:
Also, can the same measure also recalculate the rank by averaging the rank of each quote id if the user removed quote id from the row labels for the power pivot table so that power pivot table would look like this:
Any help appreciated.
Ranking =
IF (
ISFILTERED ( Quotes[Quote] ),
RANKX ( FILTER ( ALLSELECTED ( Quotes[Company] ), [Rate Total] ), [Rate Total],, ASC ),
AVERAGEX (
VALUES ( Quotes[Quote] ),
RANKX ( FILTER ( ALLSELECTED ( Quotes[Company] ), [Rate Total] ), [Rate Total],, ASC )
)
)
I have added a measure to calculate difference to yesterday's figures however
when it is Monday's figure it returns blank instead of comparing against Friday's figure.
Is there a way of asking sales figure from two days ago, I tried deducting 2 as per
previous Day Sales:=CALCULATE(
sum(Sales[1]),
PREVIOUSDAY(Calender[Date]-2))
But it didn't work
Any suggestions please?
Thanks,
B
Assuming in your context is present Sales[Date] or Calendar[Date] column you can get the previous date with sales by using a FILTER:
Previous Day Sales :=
CALCULATE (
SUM ( Sales[Sales] ),
FILTER (
ALL ( Sales ),
Sales[Date]
= CALCULATE (
MAX ( Sales[Date] ),
FILTER (
ALL ( Sales ),
COUNTROWS ( FILTER ( Sales, EARLIER ( Sales[Date] ) < Sales[Date] ) )
)
)
)
)
This is an example in Power BI, but works in Power Pivot (Excel) too.
Hope it helps.
Thanks in advance for helping this struggling newbie.
Can this aggregation be done with a single DAX statement?
I need to get to the "50" result using a measure if possible...
excel data screen capture
Here is a DAX measure performing this calculation (replace YourTable with the actual table name):
=
SUMX (
VALUES ( YourTable[Item] ),
MAXX (
VALUES ( YourTable[Round] ),
CALCULATE( SUM ( YourTable[Value] ) )
)
)
This measure uses nested iterators SUMX and MAXX to iterate over the Item and Round dimensions.