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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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())

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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

July 2024 Power BI Update

Power BI Monthly Update - July 2024

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

July Newsletter

Fabric Community Update - July 2024

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