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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
emillia1991
New Member

hiding empty columns in the matrix based on measures

Dear communty,

I'm new here and using Power BI since few months.

I wanted to present sales and sales difference in two different points in time. I want to choose points in time in slicer. My problem is that I have empty columns:

emillia1991_1-1662034047923.png

 

 

I created D_sales by applying measures, so that I can choose two years and it will calculate the percentage difference for these two years. Below the measures I used:

D_sales = 100*(DIVIDE(
    [Diff_sales],
    CALCULATE(
        SUM('Sheet1'[sales]),
        FILTER('Sheet1',Sheet1[year]=MIN(
            'Sheet1'[year]))
    )
))
 
 
Diff_sales = IF(
    HASONEVALUE('Sheet1'[year]),
    BLANK (),
    CALCUlATE(
        SUM(Sheet1[sales]),
        FILTER('Sheet1','Sheet1'[year]=MAX(Sheet1[year]
        ))
)
        - CALCULATE(
            SUM(Sheet1[sales]),
            FILTER('Sheet1','Sheet1'[year]=MIN(Sheet1[year]
            ))
        )
)

 

Hiding these empty columns by dragging is not possible because I want to update data and choose different years in the filter. I'm searching the Internet since yesterday. However, I'm not very succesful.  I was wondering if it is possible to write sth in the code so that it won't display empty columns.

2 REPLIES 2
amitchandak
Super User
Super User

@emillia1991 , Try like

 

Diff_sales =
var _max = maxx(allselected(Sheet) ,Sheet1[year])
var _min = Minx(allselected(Sheet) ,Sheet1[year])
return
IF(
HASONEVALUE('Sheet1'[year]),
BLANK (),
CALCUlATE(
SUM(Sheet1[sales]),
FILTER('Sheet1','Sheet1'[year]=_max
))
- CALCULATE(
SUM(Sheet1[sales]),
FILTER('Sheet1','Sheet1'[year]=_min
))
)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thank you @amitchandak for your reply. Unfortunately it doesn't work. I still see the empty columns 😞

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.