Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hello All,
I need to calculate the sum of values as,
For above table,
For Month-Year Apr-2016----> _Sum OF headcount = Apr-2016 value(there's no previous month values),
Month-Year May-2016----> _Sum OF headcount = Apr-2016 _HeadCount value +May-2016 _HeadCount Value,
Month-Year Jun-2016----> _Sum OF headcount = Apr-2016 _HeadCount value +May-2016 _HeadCount Value +Jun-2016 _HeadCount Value,
Like wise i need to calculate the sum of headcount values for that perticular month to previous month values for every month.
Any help Please.
Mohan V
Solved! Go to Solution.
@Anonymous
Similarly you can adjust the MEASURE
Measure = CALCULATE ( SUM ( TableName[HeadCount] ), FILTER ( ALLEXCEPT ( TableName, TableName[Gender] ), TableName[Month Year] <= SELECTEDVALUE ( ( TableName[Month Year] ) ) ) )
How about something like:
SumHeadcount = VAR CurrentMonth LASTDATE('YourTable'[MonthYear]) VAR LastMonthNum = if(Month(CurrentMonth) = 1, 12, MONTH(CurrentMonth) - 1) VAR LastMonth = if(Month(CurrentMonth) = 1, DATE(YEAR(CurrentMonth]) - 1, LastMonthNum, 1), DATE(YEAR(CurrentMonth]), LastMonthNum, 1)) RETURN CALCULATE( SUM('YourTable'[_Headcount]), ALL('YourTable') 'YourTable'[Month Year] >= LastMonth, 'YourTable'[Month Year] <= CurrentMonth )
If your headcount is actually a measure, you can replace "SUM('YourTable'[_Headcount])" with your measure.
Hi @Anonymous
Try this Calculated Column
= CALCULATE ( SUM ( TableName[HeadCount] ), FILTER ( ALL ( TableName ), TableName[Month Year] <= EARLIER ( TableName[Month Year] ) ) )
@Anonymous
As a MEASURE you could try
Measure = CALCULATE ( SUM ( TableName[HeadCount] ), FILTER ( ALL ( TableName ), TableName[Month Year] <= SELECTEDVALUE ( ( TableName[Month Year] ) ) ) )
@Anonymous @Zubair_Muhammad All your suggestions are worked like a charm
You guys are awsome.
Perfect.
But here i got an issue that,
when i included Gender in this table then it didnt given values as expected.
Here i would like to get the sum value as
for Gender Female type of 4/1/2016 = 2548,
Now this should get summed with 5/1/2016 Female value and should give 2548+2556=5104
Like wise it should get summed values for all the months
Is it possible.??
Hi @Anonymous
Just replace ALL(TableName) with ALLexcept( TableName ,TableName[Gender])
= CALCULATE ( SUM ( TableName[HeadCount] ), FILTER ( ALLEXCEPT ( TableName, TableName[Gender] ), TableName[Month Year] <= EARLIER ( TableName[Month Year] ) ) )
@Anonymous
Similarly you can adjust the MEASURE
Measure = CALCULATE ( SUM ( TableName[HeadCount] ), FILTER ( ALLEXCEPT ( TableName, TableName[Gender] ), TableName[Month Year] <= SELECTEDVALUE ( ( TableName[Month Year] ) ) ) )
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
113 | |
97 | |
85 | |
70 | |
61 |
User | Count |
---|---|
151 | |
121 | |
104 | |
87 | |
67 |