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

Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more

Reply
bdehning
Post Prodigy
Post Prodigy

Do not show Years with no Data on Visual

I have the followomng PBIX file.   https://drive.google.com/file/d/12jtqlGafWDMJSNIl1S8NtJuE8uB-MuJL/view?usp=drive_link

Can someone help take this farther and look at the _Include Measure and help fix it, so we not see all the blank years like below?   We just want to see the 3 lastest years only  For the Cust 2 only 2020, 2023 and 2024 should show on the X Axis.   

bdehning_0-1744688987797.png

 

1 ACCEPTED SOLUTION
danextian
Super User
Super User

Hi @bdehning 

 

Try this measure as  visual filter  and ensure that the X-axis is set to categorical.

Year Rank = 
RANKX (
    FILTER ( ALLSELECTED ( 'Date'[Year] ), NOT ( ISBLANK ( [Sales] ) ) ),
    CALCULATE ( MAX ( 'Date'[Year] ) ),
    ,
    DESC,
    DENSE
)

 

danextian_0-1744703635578.png

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

6 REPLIES 6
danextian
Super User
Super User

Hi @bdehning 

 

Try this measure as  visual filter  and ensure that the X-axis is set to categorical.

Year Rank = 
RANKX (
    FILTER ( ALLSELECTED ( 'Date'[Year] ), NOT ( ISBLANK ( [Sales] ) ) ),
    CALCULATE ( MAX ( 'Date'[Year] ) ),
    ,
    DESC,
    DENSE
)

 

danextian_0-1744703635578.png

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Yes your measure worked on the sample report. 

Now I need to try to get that or a verison of that to work on my Dashboard Chart that is more complicated. 

bdehning_0-1744765150586.png

I am trying to show only 3 years or 3 INCEPTIONDATE in this case.   When I apply your Year Rank I see this.  I use 3 measures to help provide the Top 3 Injury Cause for the last 3 INCEPTIONDATE Years.  You can see i have Injury Cause on X Axis and Count on Y Axis and Legenc provides the INCEPTIONDATE.  

 

bdehning_1-1744765231270.png

 

 

pankajnamekar25
Impactful Individual
Impactful Individual

Hello @bdehning 

 

Use this measure on Visual level filter

 

Show Latest 3 Years =

VAR SelectedCust = SELECTEDVALUE('Customer'[Customer])

VAR AllYearsWithData =

    CALCULATETABLE(

        VALUES('Date'[Year]),

        NOT ISBLANK([Sales]),  // Replace [Sales] with your actual measure

        'Customer'[Customer] = SelectedCust

    )

VAR Top3Years =

    TOPN(3, AllYearsWithData, 'Date'[Year], DESC)

RETURN

    IF(MAX('Date'[Year]) IN Top3Years, 1, 0)

 

 

Thanks,
 Pankaj Namekar | LinkedIn

If this solution helps, please accept it and give a kudos (Like), it would be greatly appreciated.

Your measure says this when trying to save    A function 'PLACEHOLDER' has been used in a True/False expression that is used as a table filter expression. This is not allowed.  

powerbidev123
Solution Sage
Solution Sage

Hi @bdehning , in your visual level filter . Deselect the 2021 2022 2025 years. 

The slicer on Cover is selecting the Customer.  So there will not be slicer on page 1.   

 

https://drive.google.com/file/d/104cWzIh7ei2zwQzFjXR1LkFAy6odeE7X/view?usp=drive_link


Helpful resources

Announcements
PBIApril_Carousel

Power BI Monthly Update - April 2025

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

Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

April2025 Carousel

Fabric Community Update - April 2025

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

Top Solution Authors