Forum Discussion
Mario_the_Diver
6 years agoNew Member
Calculating Mode for a calculated value ( temporary Table)
I am struggeling since a while with the Problem to calculate th mode for [OrderQuantity] which is not a field of my Factstable FactInc Since FactsInc is the Report of the Incomes in ourIncomedepartm...
v-frfei-msft
6 years agoCommunity Support
Hi Mario_the_Diver ,
We can update the formula as below.
Table =
VAR TempTab1 =
ADDCOLUMNS (
VALUES ( FactsInc[OrderNr.] ),
" OrderQuantity ", CALCULATE ( SUMX ( FactsInc, FactsInc[Quantity] ) )
)
var tempTab2=
ADDCOLUMNS (
TempTab1,
"Frequency", CALCULATE (
DISTINCTCOUNT ( FactsInc[OrderNr.] ),
FILTER ( TempTab1, [ OrderQuantity ] = EARLIER ( [ OrderQuantity ] ) )
)
)
return
tempTab2
For more details, please check the pbix as attached.
Mario_the_Diver
6 years agoNew Member
Sorry to answer late ( had some days off)
Your code is hard to understand for me
var tempTab2=
ADDCOLUMNS (
TempTab1,
"Frequency", CALCULATE (
DISTINCTCOUNT ( FactsInc[OrderNr.] ), // Why Counting the OrderNr. in FactsInc which is not filtered by comming FILTER
FILTER ( TempTab1, [ OrderQuantity ] = EARLIER ( [ OrderQuantity ] ) ) //EARLIER because of Calculate
)
)