Forum

Getting the value o...
 
Notifications
Clear all

Getting the value of the current month

6 Posts
3 Users
0 Reactions
79 Views
(@shantanu-krisgmail-com)
Posts: 12
Eminent Member
Topic starter
 

Capture.JPGHi Mynda,

I am trying to calculate employee count for the most current month. For that, i am using this query:

EMPCOUNT:=CALCULATE(COUNTROWS('Consolidated Report'),FILTER('Consolidated Report','Consolidated Report'[End of Month]=[LASTDATE]))

I am using Last Date function to identify the last date in the dates column & then use it to filter the table to identify employee count for a particular month.

I am not getting the correct answer - infact getting the entire count of rows when it should just throw the count of rows of the last month.

I am attaching the snapshot of my power pivot window.

Thanks 

Shantanu 

 
Posted : 21/04/2019 9:14 am
(@catalinb)
Posts: 1937
Member Admin
 

Hi,

Don't expect to see the correct values in Power Pivot editor.

The measures should be designed to calculate the correct values in a pivot table context, the only way to see if your measure works is to create a pivot table and display the measure with your desired pivot table structure.

In power Pivot editor window, [LastDate] will always be ... the last date, because there is no row context in there, there can be a row context only in a pivot table or in a table column.

You might need to use FILTER(ALL('Consolidated Report'),...., in a pivot table context the measure is sensitive to the row context.

 
Posted : 21/04/2019 12:19 pm
(@shantanu-krisgmail-com)
Posts: 12
Eminent Member
Topic starter
 

Hi,

 

Thanks for the response but I am not able to crack it. What is wrong in the formula?

 
Posted : 21/04/2019 10:08 pm
(@catalinb)
Posts: 1937
Member Admin
 

Can you attach a screenshot of your pivot table with the wrong count displayed?

 
Posted : 22/04/2019 12:08 am
(@shantanu-krisgmail-com)
Posts: 12
Eminent Member
Topic starter
 

Hi,

I am attaching 2 snapshots.

Pivot table that shows the correct number of employees for all months together ( even when the filter is last month filter in the formula above) & the power pivot window.

The last Month measure created-is correcting identifying the last month of that column. However, when I use it in calculate function, it is not filtering the data by last month. 

Ideally in the pivot table- when I use the measure EMPCOUNT, I should get the count of only the most recent month & not for all months together.

What am I missing?

 

Capture-1.JPGCapture2.JPG

 
Posted : 22/04/2019 2:42 am
(@mynda)
Posts: 4762
Member Admin
 

Hi Shantanu,

As Catalin said: "In power Pivot editor window, [LastDate] will always be ... the last date, because there is no row context in there, there can be a row context only in a pivot table or in a table column."

Your PivotTable doesn't have a date field in it, therefore the measure has no context to know what is the 'last month'.

Try moving the gender to the column labels and put a date field in the PivotTable row labels.

Mynda

 
Posted : 22/04/2019 7:55 pm
Share: