Effacer les filtres
Effacer les filtres

Sum quarterly rows into annual results of revenue

1 vue (au cours des 30 derniers jours)
Philip Chindamo
Philip Chindamo le 28 Fév 2019
Capture.PNG

Réponses (1)

Akira Agata
Akira Agata le 1 Mar 2019
How about the following?
% Create data table with same structure of yours
Date = repelem(datetime(2017,3,1)+3*calmonths(0:3),1,3)';
Code = repmat(categorical({'abc','def','ghi'}),1,4)';
Quantity = randi(100,12,1);
Price = randi(10,12,1)/10;
T = table(Date,Code,Quantity,Price);
% Calculate yearly revenue for each code
group = findgroups(T.Code);
Revenue =...
splitapply(@(x,y) sum(x.*y),T.Quantity,T.Price,group);

Catégories

En savoir plus sur Financial Toolbox dans Help Center et File Exchange

Produits

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by