Forum Discussion
Summarizing a table to align most recent dates
- 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 :
I updated the date information in the Fact table to reflect actual dates as you originally suggested:
In a visual, it looks like this:
From the above table, you can see that for the latest 3 transactions:
East (5 - A, 6 - B and 8 - C) yields C vendor
North ( 7+4 + 3= 14) yields B vendor
South ( (8+2)= 10 B, 3 - A) yields B vendor
West (1 + 1 = 2 for D, 1 for C) yields D vendor
I'll work on how to add a link to my updated model, but you get the idea. It looks like maybe you are taking the most recent 3 transactions for each vendor, then doing the comparison? The idea is to find the vendor that is currently (based on the latest 3 transactions) providing qty, not the one that provided the most qty over the history. Thanks!
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])
)
)
)
- Anonymous2 years agoNot applicable
xifeng_L THANK YOU!