Forum Discussion
SUM by category
- 4 years ago
Hi Anonymous
Here is the sample file with the solution https://www.dropbox.com/t/GTSytgeJpOM8WoQO
One way to that is by starting with a calculated column that retrieves the last date as per your requirement.Last Date = VAR CurrentCatEspTable = FILTER ( Data, Data[Cat] = EARLIER ( Data[Cat] ) && Data[Esp] = EARLIER ( Data[Esp] ) ) VAR Result = MAXX ( CurrentCatEspTable, Data[Date] ) RETURN ResultThen we can create our measure
CatSUM = CALCULATE ( SUM ( Data[Mount] ), REMOVEFILTERS(), VALUES ( Data[Cat] ), FILTER ( ALL ( Data ), Data[Date] = Data[Last Date] ) )The report looks like this
Please let me know if this answers your query. Have a great day!
Hi Anonymous
Here is the sample file with the solution https://www.dropbox.com/t/GTSytgeJpOM8WoQO
One way to that is by starting with a calculated column that retrieves the last date as per your requirement.
Last Date =
VAR CurrentCatEspTable =
FILTER (
Data,
Data[Cat] = EARLIER ( Data[Cat] )
&& Data[Esp] = EARLIER ( Data[Esp] )
)
VAR Result =
MAXX ( CurrentCatEspTable, Data[Date] )
RETURN
ResultThen we can create our measure
CatSUM =
CALCULATE (
SUM ( Data[Mount] ),
REMOVEFILTERS(),
VALUES ( Data[Cat] ),
FILTER (
ALL ( Data ),
Data[Date] = Data[Last Date]
)
)The report looks like this
Please let me know if this answers your query. Have a great day!
Hello,
this is the real calculated column :
- tamerj14 years ago
Community Champion
How does that relate to your original query?
- Anonymous4 years agoNot applicable
Hi,
Sorry it's bad manipulation and the wrong query,
I try to use your measure and it's working but if i have two years it's make the total of all years How can i calculate the measure and get the result by year ?
After use the result in a calculated column and found which cat have the total mount by year greter than 100 ?
Thank you for your help- tamerj14 years ago
Community Champion
Hi Anonymous
Then use this code for be able to curry out your calculations per yearLast Date = VAR CurrentCatEspTable = FILTER ( Data, Data[Cat] = EARLIER ( Data[Cat] ) && Data[Esp] = EARLIER ( Data[Esp] ) && YEAR ( Data[Date] ) = YEAR ( EARLIER ( Data[Date] ) ) ) VAR Result = MAXX ( CurrentCatEspTable, Data[Date] ) RETURN Result
- Anonymous4 years agoNot applicable
Details : With catSum for CAT =A i have 108 for lastDate =05/01/2021 but if in my dataset i have for cat =A another Esp with lastdate=01/01/2022 the CatSum is gonna be the same and i want a catsum by year and cat too.
Thank you