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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
TCatron18
Helper II
Helper II

Matrix to Not Display Months Without Data

Hello!

I have a matrix with several measures displaying YTD data by month. I am having an issue with one of my measures populating data in months that don't have any other relevant data. 

I was able to create this measure for one of the scenarios I needed to account for. That scenario being that another measure was equal to 1.

Total Emp Count =
VAR MinDate = FIRSTDATE ( 'Date'[Date] )
VAR MaxDate = LASTDATE ( 'Date'[Date] )
VAR SysGen = [Measure 1]
VAR EmpCount =
CALCULATE (
COUNTROWS ( 'Census' ),
( 'Census'[DATE] >= MinDate
&& 'Census'[DATE] <= MaxDate )
)
Return
IF( SysGen = 1, 1, EmpCount - [Measure 2] )
 
The measure I am having the issue with is the following. In this scenario, if the row value equals 'xSystem Generated' then I was it to populate 1 otherwise populate the appropriate value. I can't use the same logic as above because for this section of the matrix [Measure 1] does not equal 1. The below does populate a 1 in the field I need it to, but it's also populating it in future months that do not have any other applicable data.
Total EE Count =
VAR MinDate = FIRSTDATE ( 'Date'[Date] )
VAR MaxDate = LASTDATE ( 'Date'[Date] )
VAR SysGen = SELECTEDVALUE ( 'Table'[Value] )
VAR EECount =
CALCULATE (
COUNTROWS ( 'Census' ),
( 'Census'[Date] >= MinDate
&& 'Census'[Date] <= MaxDate )
)
RETURN
IF ( SysGen = "xSystem Generated", 1, EECount )
 
Any help is truly appreciated!
Thanks!!
1 ACCEPTED SOLUTION

Hi @TCatron18,

 

Thank you for reaching out to Microsoft Fabric Community.

 

Based on your requirement, here the issue is like the xSystem Generated rows showing as 1 even when no actual data exists for that month. Please use below measure:

 

Total EE Count =

VAR MinDate = FIRSTDATE('Date'[Date])

VAR MaxDate = LASTDATE('Date'[Date])

VAR SysGen = SELECTEDVALUE('Table'[Value])

VAR EECount =

    CALCULATE (

        COUNTROWS('Census'),

        'Census'[Date] >= MinDate && 'Census'[Date] <= MaxDate

    )

VAR HasData =

    CALCULATE (

        COUNTROWS('Census'),

        REMOVEFILTERS('Table'[Value]),

        'Census'[Date] >= MinDate && 'Census'[Date] <= MaxDate

    ) > 0

RETURN

    IF (

        HasData,

        IF ( SysGen = "xSystem Generated", 1, EECount ),

        BLANK()

    )

This will check whether any real census data exists for the current month and return 1 if valid.

Make sure that the 'Show items with no data' option is disabled for the month columns in the matrix visual.

 

If this post helps, then please consider Accepting as solution to help the other members find it more quickly, don't forget to give a "Kudos" – I’d truly appreciate it! 

 

Thanks and regards,

Anjan Kumar Chippa

View solution in original post

11 REPLIES 11
TCatron18
Helper II
Helper II

@Ashish_Excel Here is my sample data pbix. I am looking for the Total EE Count (or Total EE Count TEST - this is using the new code provided by @bhanu_gautam) to display '1' in that column when the Company is 'xSystem Generated'. 

https://drive.google.com/file/d/1hSHiz73gTE10p_GDFwSVOaonXKakXElk/view?usp=sharing 

Access Denied message.

@Ashish_Excel Apologies. I've updated the sharing. 

Your question has already been answered by another user.

Ashish_Excel
Super User
Super User

Hi,

Share some data to work with, explain the question and show the expected result.  Share data in a format that can be pasted in an MS Excel file.

bhanu_gautam
Super User
Super User

@TCatron18 Try using

dax
Total EE Count =
VAR MinDate = FIRSTDATE ( 'Date'[Date] )
VAR MaxDate = LASTDATE ( 'Date'[Date] )
VAR SysGen = SELECTEDVALUE ( 'Table'[Value] )
VAR HasData =
CALCULATE (
COUNTROWS ( 'Census' ),
( 'Census'[Date] >= MinDate && 'Census'[Date] <= MaxDate )
) > 0
VAR EECount =
CALCULATE (
COUNTROWS ( 'Census' ),
( 'Census'[Date] >= MinDate && 'Census'[Date] <= MaxDate )
)
RETURN
IF ( HasData, IF ( SysGen = "xSystem Generated", 1, EECount ), BLANK() )




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






@bhanu_gautam That does move the future months where no data exists; however, it is not populating the '1' in the field when the row value = xSystem Generated.

TCatron18_0-1748537555255.png

 

@TCatron18 , Try using

dax
Total EE Count =
VAR MinDate = FIRSTDATE ( 'Date'[Date] )
VAR MaxDate = LASTDATE ( 'Date'[Date] )
VAR SysGen = SELECTEDVALUE ( 'Table'[Value] )
VAR HasData =
CALCULATE (
COUNTROWS ( 'Census' ),
( 'Census'[Date] >= MinDate && 'Census'[Date] <= MaxDate )
) > 0
VAR EECount =
CALCULATE (
COUNTROWS ( 'Census' ),
( 'Census'[Date] >= MinDate && 'Census'[Date] <= MaxDate )
)
RETURN
IF ( HasData, IF ( SysGen = "xSystem Generated", 1, EECount ), BLANK() )




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






@bhanu_gautam I don't see that there is a difference between this DAX and the original one you posted. Am I missing something? 

Hi @TCatron18,

 

Thank you for reaching out to Microsoft Fabric Community.

 

Based on your requirement, here the issue is like the xSystem Generated rows showing as 1 even when no actual data exists for that month. Please use below measure:

 

Total EE Count =

VAR MinDate = FIRSTDATE('Date'[Date])

VAR MaxDate = LASTDATE('Date'[Date])

VAR SysGen = SELECTEDVALUE('Table'[Value])

VAR EECount =

    CALCULATE (

        COUNTROWS('Census'),

        'Census'[Date] >= MinDate && 'Census'[Date] <= MaxDate

    )

VAR HasData =

    CALCULATE (

        COUNTROWS('Census'),

        REMOVEFILTERS('Table'[Value]),

        'Census'[Date] >= MinDate && 'Census'[Date] <= MaxDate

    ) > 0

RETURN

    IF (

        HasData,

        IF ( SysGen = "xSystem Generated", 1, EECount ),

        BLANK()

    )

This will check whether any real census data exists for the current month and return 1 if valid.

Make sure that the 'Show items with no data' option is disabled for the month columns in the matrix visual.

 

If this post helps, then please consider Accepting as solution to help the other members find it more quickly, don't forget to give a "Kudos" – I’d truly appreciate it! 

 

Thanks and regards,

Anjan Kumar Chippa

Hi @v-achippa  - Thank you that worked perfectly 🙂 

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

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.