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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Dimitris_Kats
Helper V
Helper V

Can't remove Blank rows

Hello members.

I have a measure that works well but when I am trying to remove blanks from Filters then I get an error.
Specifically, I am checking if there are any salary changes month over month.

I am using 3 measures:

Salary CM = Calculate(SUM(HR[Salary]))


Salary PM = CALCULATE( SUM(Table1[Salary]),DATEADD('Time'[Month] , -1 , MONTH))


Salary Dif = IF(ISBLANK([Salary CM]),BLANK(),IF(ISBLANK([Salary PM]),BLANK(),IF([Salary CM]=[ Salary PM],BLANK(),[Salary CM]-[ Salary PM])))


I am using a Calendar table and the month column that I am using in the measures has a date format.

The measures works perfectly especially if I don't have a month slicer.

When i am adding a slicer and I am choosing for example 2 months I get some blank rows with the employees that was new hires.
I tried to remove those BLANKS by adding a filter that "Salary Dif" is not BLANK but I get an error:

Calculation error in measure Table1 [Salary PM]: Function 'DATEADD' expects a contiguous selection when the date column is not unique, has gaps or it contains time portion.

 

Date          Salary    EmployeeID
1/12/2021  800       99
1/12/2021  1000     100
1/12/2021  900      101
1/12/2021  1100    102
1/1/2022   1000     100
1/1/2022    900      101
1/1/2022   1100     102
1/1/2022   1300     103
1/2/2022   1400     100
1/2/2022   900       101
1/2/2022   1100     102
1/2/2022   1500     103
1/3/2022   1400     100
1/3/2022   1000     101
1/3/2022   1100     102
1/3/2022   1500     103
1/3/2022   1200     104
1/4/2022   1400     100
1/4/2022   1000     101
1/4/2022   1100     102
1/4/2022   1500     103
1/4/2022   1200    104

 

Is there any way to remove tha blank rows??

Thank you in advance, your help is always greatly appreciated

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

Hi, @Dimitris_Kats 

 

Do you choose two non-consecutive months on the slicer? If you need to use dateadd function, you can only select consecutive months. If you don't want to select consecutive months, you may need to add year to slicer as well, then you can try like this:

Measure3 =
VAR a =
    MIN ( 'Time'[Date] ) - 1
VAR b =
    EOMONTH ( MAX ( 'Time'[Date] ), -1 )
VAR c =
    DATE ( YEAR ( a ), MONTH ( a ), 1 )
VAR d =
    DATE ( YEAR ( b ), MONTH ( b ), 1 )
RETURN
    SUMX (
        FILTER (
            ALL ( 'Table1' ),
            (
                RELATED ( 'Time'[Date] ) >= c
                    && RELATED ( 'Time'[Date] ) <= a
            )
                || (
                    RELATED ( 'Time'[Date] ) >= d
                        && RELATED ( 'Time'[Date] ) <= b
                )
        ),
        [Salary]
    )

  

vjaneygmsft_0-1650610345538.png

Did I answer your question? Please mark my reply as solution. Thank you very much.
If not, please feel free to ask me.

Best Regards,
Community Support Team _ Janey

View solution in original post

1 REPLY 1
v-janeyg-msft
Community Support
Community Support

Hi, @Dimitris_Kats 

 

Do you choose two non-consecutive months on the slicer? If you need to use dateadd function, you can only select consecutive months. If you don't want to select consecutive months, you may need to add year to slicer as well, then you can try like this:

Measure3 =
VAR a =
    MIN ( 'Time'[Date] ) - 1
VAR b =
    EOMONTH ( MAX ( 'Time'[Date] ), -1 )
VAR c =
    DATE ( YEAR ( a ), MONTH ( a ), 1 )
VAR d =
    DATE ( YEAR ( b ), MONTH ( b ), 1 )
RETURN
    SUMX (
        FILTER (
            ALL ( 'Table1' ),
            (
                RELATED ( 'Time'[Date] ) >= c
                    && RELATED ( 'Time'[Date] ) <= a
            )
                || (
                    RELATED ( 'Time'[Date] ) >= d
                        && RELATED ( 'Time'[Date] ) <= b
                )
        ),
        [Salary]
    )

  

vjaneygmsft_0-1650610345538.png

Did I answer your question? Please mark my reply as solution. Thank you very much.
If not, please feel free to ask me.

Best Regards,
Community Support Team _ Janey

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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