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

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.

Reply
hilvie
Frequent Visitor

Supressing values from a table

Hi there,

I`m using measures to determine the difference between months (current en past year). The financial table uses a number for a month and I have a date table connected with it. I have a visual that shows the values but I dont want it to show the coming months. I`ve been trying to hide with a switch but then it only shows the current month. Any ideas what i`m doing wrong?

What I`m trying to achieve. A table that only shows the current and past months
Current month august, so sep-dec should be empty
MONTH Difference
1 10
2 30
3 40
4 -20
5 -50
6 80
7 10
8 12
9
10
11
12

My Code:
CheckMonthDiff =
VAR CurrentMonth = MONTH (TODAY ())
RETURN

Switch ( True(),
IF([CurrentMonth] <= 1,"",[JanMonthDiff]),
IF([CurrentMonth] <= 2,"",[FebMonthDiff]),
IF([CurrentMonth] <= 3,"",[MarMonthDiff])
...
...
IF([CurrentMonth] <= 12,"",[DecMonthDiff])
)

1 ACCEPTED SOLUTION
v-jianboli-msft
Community Support
Community Support

Hi @hilvie ,

 

Based on your description, I have created a simple sample like this:

vjianbolimsft_0-1661219116031.png

vjianbolimsft_1-1661219128868.png

 

Please try:

 

Diff =
VAR _currentyear =
    YEAR ( TODAY () )
RETURN
    IF (
        MAX ( 'Calendar'[Month] ) <= MONTH ( TODAY () ),
        SUMX (
            FILTER (
                'Table',
                [Month] = MAX ( 'Calendar'[Month] )
                    && YEAR ( [Date] ) = _currentyear
            ),
            [Value]
        )
            - SUMX (
                FILTER (
                    'Table',
                    [Month] = MAX ( 'Calendar'[Month] )
                        && YEAR ( [Date] ) = _currentyear - 1
                ),
                [Value]
            )
    )

 

Then select show items with no data:

vjianbolimsft_2-1661219167616.png

Final Output:

vjianbolimsft_3-1661219190708.png

If the result is not what you want, please provide me with more details about your table and your problem or share me with your pbix file after removing sensitive data.

 

Refer to:

How to provide sample data in the Power BI Forum

How to Get Your Question Answered Quickly

 

Best Regards,

Jianbo Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

3 REPLIES 3
v-jianboli-msft
Community Support
Community Support

Hi @hilvie ,

 

Based on your description, I have created a simple sample like this:

vjianbolimsft_0-1661219116031.png

vjianbolimsft_1-1661219128868.png

 

Please try:

 

Diff =
VAR _currentyear =
    YEAR ( TODAY () )
RETURN
    IF (
        MAX ( 'Calendar'[Month] ) <= MONTH ( TODAY () ),
        SUMX (
            FILTER (
                'Table',
                [Month] = MAX ( 'Calendar'[Month] )
                    && YEAR ( [Date] ) = _currentyear
            ),
            [Value]
        )
            - SUMX (
                FILTER (
                    'Table',
                    [Month] = MAX ( 'Calendar'[Month] )
                        && YEAR ( [Date] ) = _currentyear - 1
                ),
                [Value]
            )
    )

 

Then select show items with no data:

vjianbolimsft_2-1661219167616.png

Final Output:

vjianbolimsft_3-1661219190708.png

If the result is not what you want, please provide me with more details about your table and your problem or share me with your pbix file after removing sensitive data.

 

Refer to:

How to provide sample data in the Power BI Forum

How to Get Your Question Answered Quickly

 

Best Regards,

Jianbo Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Thank you for this!!!!

I`ve added a YEAR column and the visual works:

hilvie_0-1661238472949.png

 

lbendlin
Super User
Super User

Please provide sanitized sample data that fully covers your issue. I can only help you with meaningful sample data.
Please paste the data into a table in your post or use one of the file services like OneDrive or Google Drive.
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...

Please show the expected outcome based on the sample data you provided. Screenshots of the expected outcome are ok.

https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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