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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Pavanpoosoju09
New Member

How to show only common classes between Current Month and Previous Month visuals?

Hi Experts,

I have two visuals in my report:

  • Current Month Income by Class

  • Previous Month Income by Class

My data model has these tables:

  • P&L Data → Year, Month, Class, Amount

  • Class Master → All available classes (A–L)

  • Dim Date → Calendar
    Measures:-Current Month Income,Previous Month Income

    Pavanpoosoju09_2-1755344845140.png

     

     

    The issue:

    • In Jan 2025, the current month has only 6 classes with data (A–F).

    • The previous month (Dec 2024) has 10 classes with data (A–J).

    • The Class Master table has 12 classes (A–L).

    Right now, both visuals show all 12 classes, with zeros where there is no data.
    But what I want is:
    Only the classes that exist in both current month and previous month (i.e. common classes, A–F in this case).

    Refer the link for Pbix File:-
    https://drive.google.com/file/d/1hmLYMjrC8ZgHMS8irjHwuJeMs05erL3u/view?usp=drive_link

3 REPLIES 3
DataNinja777
Super User
Super User

Hi @Pavanpoosoju09 ,

 

You can achieve this by creating a DAX measure that identifies which classes have data in both the current and previous months. This measure can then be used as a filter on your visuals to only show those common classes.

First, you will need to create a new measure in your Power BI report. You can do this by navigating to the Home or Modeling tab and selecting New Measure. In the formula bar, you should enter the following DAX expression. This formula checks if a class has income in both the current and previous month periods. If it has income in both, the measure returns a value of 1; otherwise, it returns a blank value.

Show Common Classes = 
IF(
    NOT ISBLANK([Current Month Income]) && NOT ISBLANK([Previous Month Income]),
    1,
    BLANK()
)

After creating the measure, you need to apply it as a filter to both of your visuals. Select the "Current Month Income by Class" visual to begin. With the visual selected, open the Filters pane. Drag your newly created Show Common Classes measure into the "Filters on this visual" area. A new filter card will appear. Here, you will set the filter condition to show items when the value "is 1" and then click Apply filter. You will then repeat this exact same process for the "Prev Month Income by Class" visual. Once applied to both charts, they will dynamically update to display only the classes that are common to both time periods, which in your case would be classes A through F.

 

Best regards,

sanalytics
Super User
Super User

@Pavanpoosoju09 
You code should work..But it is not working only for below code.

    IF ( ISBLANK ( _Result ), 0, _Result )

and why again Treatas is there? You have already made a physical relationship bewteen class and PL table so, you dont need this virtual relationship. So the correct code should be

Current Month Income =
VAR _FinalYear = MAX ( 'Dim Date'[Year])
VAR _FinalMonth = MAX ( 'Dim Date'[Month])
VAR _Result = 
    CALCULATE (
        SUM ( 'P&L Data'[Amount] ),
        REMOVEFILTERS ( 'P&L Data'[Fiscal Year], 'P&L Data'[Class] ),
        'P&L Data'[Fiscal Year] = _FinalYear,
        'P&L Data'[Fiscal Month] = _FinalMonth
    )
VAR _BlankCheck =
    IF ( ISBLANK ( _Result ), 0, _Result )
RETURN
_Result

Below screenshot

sanalytics_0-1755353676416.png


Hope it helps.

Regards,
sanalytics

 

Thanks for your response
Explanation of the Requirement:

  • We have a total of 15 classes (A–O) across the dataset.

  • In January 2025 (current month) → only 5 classes (say A–E) have data.

  • In December 2024 (previous month)10 classes (say F–O + some of A–E) have data.

Now, on the X-axis (Class) of the charts:

  1. Both visuals If no data in Prev Month and Curr Month for same Class.

    • That exclude from both visual.

  2. If a class has data in Current Month but not in Previous Month

    • Show its value in Current Month chart.

    • Show 0 for that class in Previous Month chart.

  3. If a class has data in Previous Month but not in Current Month

    • Show its value in Previous Month chart.

    • Show 0 for that class in Current Month chart.

  4. This way, both charts line up with the same Class axis so comparison is easy.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.