Forum Discussion
Anonymous
2 years agoNot applicable
Summarizing a table to align most recent dates
I've been unable to find/figure out how to summarize a table such that the data is aligned by most recent month, prior month, prior month -1, etc. My goal is to be able to select the primary source ...
- 2 years ago
Anonymous ,
Sorry, I misunderstood your needs before. You can try below measure.
(I can't very well restore your real date due to date formatting issues, so the results may change, but the logic should be correct.)
Measure:
Primary Source = IF(HASONEFILTER('Fact'[Branch]), CALCULATE( VAR tempTable = SUMMARIZE('Fact','Fact'[source ],"Recent3MonthsTotal",SUM('Fact'[qty])) VAR MaxNbr = MAXX(tempTable,[Recent3MonthsTotal]) RETURN MAXX(FILTER(tempTable,[Recent3MonthsTotal]=MaxNbr),'Fact'[source ]), TOPN(3,VALUES('Fact'[month]),'Fact'[month]) ) )Table Expression:
Table Name = ADDCOLUMNS ( ALL ( 'Fact'[Branch] ), "Parimay Source", CALCULATE( CALCULATE( VAR tempTable = SUMMARIZE('Fact','Fact'[source ],"Recent3MonthsTotal",SUM('Fact'[qty])) VAR MaxNbr = MAXX(tempTable,[Recent3MonthsTotal]) RETURN MAXX(FILTER(tempTable,[Recent3MonthsTotal]=MaxNbr),'Fact'[source ]), TOPN(3,VALUES('Fact'[month]),'Fact'[month]) ) ) )
xifeng_L
2 years agoSuper User
Anonymous ,
Sorry, I misunderstood your needs before. You can try below measure.
(I can't very well restore your real date due to date formatting issues, so the results may change, but the logic should be correct.)
Measure:
Primary Source =
IF(HASONEFILTER('Fact'[Branch]),
CALCULATE(
VAR tempTable = SUMMARIZE('Fact','Fact'[source ],"Recent3MonthsTotal",SUM('Fact'[qty]))
VAR MaxNbr = MAXX(tempTable,[Recent3MonthsTotal])
RETURN
MAXX(FILTER(tempTable,[Recent3MonthsTotal]=MaxNbr),'Fact'[source ]),
TOPN(3,VALUES('Fact'[month]),'Fact'[month])
)
)
Table Expression:
Table Name =
ADDCOLUMNS (
ALL ( 'Fact'[Branch] ),
"Parimay Source",
CALCULATE(
CALCULATE(
VAR tempTable = SUMMARIZE('Fact','Fact'[source ],"Recent3MonthsTotal",SUM('Fact'[qty]))
VAR MaxNbr = MAXX(tempTable,[Recent3MonthsTotal])
RETURN
MAXX(FILTER(tempTable,[Recent3MonthsTotal]=MaxNbr),'Fact'[source ]),
TOPN(3,VALUES('Fact'[month]),'Fact'[month])
)
)
)
Anonymous
2 years agoNot applicable
xifeng_L THANK YOU!