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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
ArchStanton
Post Prodigy
Post Prodigy

Remove future values but keep months on x axis

Hi

 

I would like to remove the future line values from this chart but keep the Apr - Mar x axis visible.

 

ArchStanton_0-1700832635160.png

 

 

The line axis is based on this DAX code:

 

 

DD YTD Cases = CALCULATE(
    			TOTALYTD(COUNT('Cases'[Case Number]),'Date2'[Date],"31/3"))

 

 

I've seen various recommendations here but none that keep the Apr - Mar months visible

 

Can anybody help?

Thanks,

11 REPLIES 11
amitchandak
Super User
Super User

@ArchStanton , Try like

 

DD YTD Cases =
var _max = maxx(allselected('Case'), 'Case'[Case Date])
return
return if(Max(Date[Date]) <=_max ,
CALCULATE( TOTALYTD(COUNT('Cases'[Case Number]),'Date2'[Date],"31/3")), blank())

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

I don't have a column called 'Case Date' so i'm not sure how to implement this?

 

I do have a 'Created on' date in the Cases table which I've tried using but I get this error:

 

ArchStanton_0-1700837188608.png

 

DD YTD Cases2 = 
    VAR _Max = MAXX(ALLSELECTED('Cases'),'Cases'[Created On])
    RETURN
        IF(MAX(Date2[MonthName] <= _Max,
        CALCULATE(
    	TOTALYTD(COUNT('Cases'[Case Number]),'Date2'[Date],"31/3"),BLANK())))

 

The Month in my x-axis comes from the Date2 calendar table and it is sorted by FYMonthNo where APR = 1st month. Created On and Date2[Date] has an active relationship in my model.

Hi @ArchStanton ,

Please update the formula of measure as below and check if it can return the expected result...

DD YTD Cases2 =
VAR _Max =
    MAXX ( ALLSELECTED ( 'Cases' ), 'Cases'[Created On] )
RETURN
    IF (
        MAX ( Date2[MonthName] ) <= _Max,
        CALCULATE (
            TOTALYTD ( COUNT ( 'Cases'[Case Number] ), 'Date2'[Date], "31/3" ),
            BLANK ()
        )
    )

If the above one can't help you get the expected result, please provide some raw data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It would be helpful to find out the solution. You can refer the following link to share the required info:

How to provide sample data in the Power BI Forum

 

And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

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

Hi _Rena

I got this error message after using your suggestion:

 

ArchStanton_0-1701079491000.png

 

Hi @ArchStanton ,

Thanks for your feedback. Please update the formula of measure [DD YTD Cases2] as below:

DD YTD Cases2 =
VAR _Max =
    MAXX ( ALLSELECTED ( 'Cases' ), 'Cases'[Created On] )
RETURN
    IF (
        MAX ( Date2[MonthName] ) <= _Max,
        TOTALYTD ( COUNT ( 'Cases'[Case Number] ), 'Date2'[Date], "31/3" ),
        BLANK ()
    )

Best Regards

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

The formula doesn't produce any error messages anymore but when I add it to the chart I get this:

 

ArchStanton_0-1701161935074.png

 

Hi @ArchStanton ,

According to the screenshot, it seems that the condition "MAX ( Date2[MonthName] ) <= _Max" cause the error. Is the data type of field Date2[MonthName]  Text? And the data type of field 'Cases'[Created On] is Date type. Please update the formula of measure as below:

DD YTD Cases2 =
VAR _Max =
    MAXX ( ALLSELECTED ( 'Cases' ), 'Cases'[Created On] )
RETURN
    IF (
        MAX ( Date2[Date] ) <= _Max,
        TOTALYTD ( COUNT ( 'Cases'[Case Number] ), 'Date2'[Date], "31/3" ),
        BLANK ()
    )

If the above one can't help you get the expected result, please provide some raw data in your tables (exclude sensitive data) with Text format, the visual Fields settings and your expected result with backend logic and special examples. It would be helpful to find out the solution. You can refer the following link to share the required info:

How to provide sample data in the Power BI Forum

 

And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

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

Same 'Couldn't load data for this visual' merror message when I tried it.

Hi @ArchStanton ,

Could you please provide a simplified sample pbix file(remove the sensitive info)? Thank you.

How to upload PBI in Community

Best Regards

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

HI, Can you share your pbix file please? If this is working for you then it may help me to spot any differences? 

Just to reiterate, in my Date2 Calendar I have a MonthName column sorted on FYMthNumber with Apr = 1.

 

Hope that helps?

Unfortunately I can't, this is part of a very large data model that is connected to a live Case Management System. 

 

In the original Line & Bar Chart I posted, the black line is based on = 

 

 

 

 

DD YTD Cases = CALCULATE(
    			TOTALYTD(COUNT('Cases'[Case Number]),'Date2'[Date],"31/3"))

 

 

 

 

 

The green bars however are not a measure, they are just a count of Ids, they are in effect showing the same thing, except the black line which is Cumulative. The Green bars stop in Sep but the Black line continues all the way to Apr. Why is it so difficult to halt the Black line on the same month when they are based on the same data?




I find DAX incredibly frustrating as the requirement here, on paper at least, sounds straightforward. 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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

Users online (2,104)