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
JCUP
Frequent Visitor

How to prevent displaying future months in a calculation with blank = 0

Hello,

I'm using the following function in order to make the charts display the periods that don't have a value. But the problem now is that it is displaying the months in the future.

 

x Count Tickets = 
                IF
                    (
                        ISBLANK
                            (
                                DISTINCTCOUNT('Tickets DB'[Número de Ticket])
                            )
                        ,0,
                        DISTINCTCOUNT('Tickets DB'[Número de Ticket])
                    )

 

Months in the Future display

 

How can I avoid the months in the future from displaying?

 

Thanks in advance.

 

 

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

Hi @JCUP 

You could create a measure

Measure = IF(DATEDIFF(MAX('Table'[date]),TODAY(),MONTH)>0,IF(ISBLANK(SUM('Table'[value])),0,SUM('Table'[value])))

replace "sum" with "DISTINCTCOUNT" for your scenario

 

Capture14.JPGCapture15.JPG

Best Regards
Maggie

 

Community Support Team _ Maggie 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-juanli-msft
Community Support
Community Support

Hi @JCUP 

You could create a measure

Measure = IF(DATEDIFF(MAX('Table'[date]),TODAY(),MONTH)>0,IF(ISBLANK(SUM('Table'[value])),0,SUM('Table'[value])))

replace "sum" with "DISTINCTCOUNT" for your scenario

 

Capture14.JPGCapture15.JPG

Best Regards
Maggie

 

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-juanli-msft 

 

I was exploring and is not working.

 

When I have selections without data in a month (is blank), it is not calculating. Check the next image:

 

2019-09-04 09_41_30-osTicket Power BI - 2019 07 15 - Power BI Desktop.png

 

 

 

Thank you very much! It works fine.

 

If I understand it right, what we did is "IF" the date difference in months is greater than zero, then it calculates the formula "isblank...", else we do nothing.

 

For the previous months it will get a date difference in months greater than 0, for current month, and those in the future, it will display 0 (and won't calculate, therefore won't return a 0 or anything).

 

At first, I thought it would display negative values for the months in the future but it displays only zeros.

 

The inconvenient here is that it will not include current month and i already have data for it. I mean, it won't display September (we are at 2019-09-04)

 

What I did is to change the datediff period for days and now I can see september 😄

 

Thank you very much @v-juanli-msft .

 

I am adding all this explanation and the final measure, for anyone that might find it useful and to make sure I understood properly.

 

 

x Count Tickets = 
IF
    (
        DATEDIFF(MAX('Tickets DB'[Fecha]),TODAY(),DAY)>0,
                        IF
                            (
                            ISBLANK
                                (
                                    DISTINCTCOUNT('Tickets DB'[Número de Ticket])
                                )
                            ,0,
                            DISTINCTCOUNT('Tickets DB'[Número de Ticket])
                            )
    )

 

 

 

 

 

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.

Top Solution Authors