Forum Discussion
Anonymous
4 years agoNot applicable
Averagex not working as expected
Hello , I have a fact table that contains this two value i create a measure that return the Qty on hand through the year as below the result of my measure: Now , i want to calcu...
- Anonymous4 years ago
Hi Anonymous ,
Here are the steps you can follow:
1. Create calculated table.
Date = CALENDAR(DATE(2019,1,1),DATE(2019,12,31))2. Create calculated column.
left = VALUE( LEFT( RIGHT('Table'[Date Avaliavle],4),2))3. Create measure.
Qty_Month = IF( MAX('Date'[Month])>=1&&MAX('Date'[Month])<8,CALCULATE(SUM('Table'[Qty]),FILTER(ALL('Table'),'Table'[left]=1)),CALCULATE(SUM('Table'[Qty]),FILTER(ALL('Table'),'Table'[left]=8)))4. Create calculated table.
Table 2 = var _table1=SUMMARIZE('Date','Date'[Month],"if", IF( 'Date'[Month]>=1&&'Date'[Month]<8,CALCULATE(SUM('Table'[Qty]),FILTER(ALL('Table'),'Table'[left]=1)),CALCULATE(SUM('Table'[Qty]),FILTER(ALL('Table'),'Table'[left]=8)))) var _table2=ADDCOLUMNS(_table1,"count",COUNTX(FILTER(_table1,[if]=EARLIER([if])),[Month])) var _table3=ADDCOLUMNS(_table2,"amount",[if]*[count]) var _table4=SUMMARIZE(_table3,[count],[amount]) return _table45. Create measure.
average of Qty on hand = DIVIDE( SUMX(ALL('Table 2'),[amount]),SUMX(ALL('Table 2'),[count]))6. Result:
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Anonymous
4 years agoNot applicable
Hi Anonymous ,
Here are the steps you can follow:
1. Create calculated table.
Date =
CALENDAR(DATE(2019,1,1),DATE(2019,12,31))
2. Create calculated column.
left = VALUE( LEFT( RIGHT('Table'[Date Avaliavle],4),2))
3. Create measure.
Qty_Month =
IF(
MAX('Date'[Month])>=1&&MAX('Date'[Month])<8,CALCULATE(SUM('Table'[Qty]),FILTER(ALL('Table'),'Table'[left]=1)),CALCULATE(SUM('Table'[Qty]),FILTER(ALL('Table'),'Table'[left]=8)))
4. Create calculated table.
Table 2 =
var _table1=SUMMARIZE('Date','Date'[Month],"if",
IF(
'Date'[Month]>=1&&'Date'[Month]<8,CALCULATE(SUM('Table'[Qty]),FILTER(ALL('Table'),'Table'[left]=1)),CALCULATE(SUM('Table'[Qty]),FILTER(ALL('Table'),'Table'[left]=8))))
var _table2=ADDCOLUMNS(_table1,"count",COUNTX(FILTER(_table1,[if]=EARLIER([if])),[Month]))
var _table3=ADDCOLUMNS(_table2,"amount",[if]*[count])
var _table4=SUMMARIZE(_table3,[count],[amount])
return
_table4
5. Create measure.
average of Qty on hand =
DIVIDE( SUMX(ALL('Table 2'),[amount]),SUMX(ALL('Table 2'),[count]))
6. Result:
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly