Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now

Reply
Sonu88
Frequent Visitor

Excluding Departments Not Present in Last Month's Data in Power BI

Hi Expert,

 

 I'm interested in comparing the resource count between any two given months say April and May for those departments that were existed in the previous month as well. For instance, in the given table, Department 2 did not exist in the previous month, so it should be excluded from the calculation of resource count.

I need assistance to dynamically remove/filter out those departments which were not exist in previous month from my table either by power query or via DAX.

Input Data

 

ResourceDeaprtmentAssignment Date 
Resource 1Deaprtment 14/1/2024
Resource 2Deaprtment 14/1/2024
Resource 3Deaprtment 15/1/2024
Resource 4Deaprtment 25/1/2024
Resource 5Deaprtment 25/1/2024
   

Required Table

ResourceDeaprtmentAssignment Date
Resource 1Deaprtment 14/1/2024
Resource 2Deaprtment 14/1/2024
Resource 3Deaprtment 15/1/2024
2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

@lbendlin @Ashish_Mathur  Thanks for your contribution on this thread.

Hi @Sonu88 ,

You can follow the steps below to get it, please find the details in the attachment.

1. Create a measure as below

Flag = 
VAR _department =
    SELECTEDVALUE ( 'Table'[Deaprtment] )
VAR _departs =
    CALCULATETABLE (
        VALUES ( 'Table'[Deaprtment] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            MONTH ( 'Table'[Assignment Date] )
                = MONTH ( TODAY () ) - 1
        )
    )
RETURN
    IF ( _department IN _departs, 1, 0 )

2. Create a table visual and apply a visual-level filter on it with the condition (Flag is 1)

vyiruanmsft_0-1715679182086.png

Best Regards

View solution in original post

Hi,

PBI file attached.

Hope this helps.

Ashish_Mathur_0-1715737325386.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

7 REPLIES 7
Anonymous
Not applicable

@lbendlin @Ashish_Mathur  Thanks for your contribution on this thread.

Hi @Sonu88 ,

You can follow the steps below to get it, please find the details in the attachment.

1. Create a measure as below

Flag = 
VAR _department =
    SELECTEDVALUE ( 'Table'[Deaprtment] )
VAR _departs =
    CALCULATETABLE (
        VALUES ( 'Table'[Deaprtment] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            MONTH ( 'Table'[Assignment Date] )
                = MONTH ( TODAY () ) - 1
        )
    )
RETURN
    IF ( _department IN _departs, 1, 0 )

2. Create a table visual and apply a visual-level filter on it with the condition (Flag is 1)

vyiruanmsft_0-1715679182086.png

Best Regards

Ashish_Mathur
Super User
Super User

Hi,

Quite confused about what you want.  In the text, you mention that you want a count but yo have shown the expected result as a Table.  Show the expected result very clearly.  Share data in a format that can be pasted in an Excel file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hello Ashish 

 

Many apologizes,  please consider the 'Required Table' table as a desired result. Once i am able to generate the final table which excludes those departments, then I can create required measures. I hope it clean now.

If you want to compare 2 months, then atleast share data for 2 months in the sample dataset.  Your sample data has just 1 month.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi Ashish 

 

The input table has already May month data under Assignment Date column.

 

Hi,

PBI file attached.

Hope this helps.

Ashish_Mathur_0-1715737325386.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
lbendlin
Super User
Super User

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.