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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Martynas_BI
Frequent Visitor

Matching & calculating list values from the current year, that occurred in previous years

Hi,

Context:

I am working with pubclicly available data regarding Invesco‘s QQQ exchange tranded fund (ETF), which comprises of 100 publicly listed companies.

Challenge:

I want to see how many of the companies included in the year 2022 list were present in the previous years (going back 10yrs to 2013).

For example, Apple has been in the QQQ for all of the 10 years, whereas AirBnB was only included in 2022.

This is the link to the raw dataset I gathered:

https://docs.google.com/spreadsheets/d/1Sa9xva8HVuW7178WPJPV-nv0ClrqMwDM19SokaIztMM/edit#gid=0

I have manipulated it in Power Query, which looks like this:

Martynas_BI_0-1683896270154.png

 

 

My attempts that did not work:

I have tried several ways, for example, in the report view I created a slicer for the year and chose only ‘2022’, and I made this slicer not to affect the bar chart. Then in the other slicer I have the ‘ticker’ values, which represent all of the companies that were included in 2022. I thought by selecting all the values in the ticker slicer regarding 2022, it will naturally represent the count in the bar matching the ticker values for the previous years.

Martynas_BI_0-1683896685919.png

 

I have also looked at previous Power BI community threads, commonly found the LOOKUPVALUE function as a solution, however, it did not work for me.

 

Outcome/result wanted:

Ideally I would like to create a column chart showing how many companies of the 2022 list were also present in previous years.

 

Many thanks in advance

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

HI @Martynas_BI,

You can try to use the following measure formula to calculate the previous year records based on selected date:

formula =
VAR selected =
    MAX ( NewTable[Date] )
RETURN
    CALCULATE (
        'expression',
        FILTER (
            ALLSELECTED ( Table ),
            YEAR ( [Date] )
                >= YEAR ( selected ) - 9
                && YEAR ( [Date] ) <= YEAR ( selected )
        )
    )

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

2 REPLIES 2
Ashish_Mathur
Super User
Super User

Hi,

I am not clear about the chart that you want.  What do you want to see on the X-axis of the column chart?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-shex-msft
Community Support
Community Support

HI @Martynas_BI,

You can try to use the following measure formula to calculate the previous year records based on selected date:

formula =
VAR selected =
    MAX ( NewTable[Date] )
RETURN
    CALCULATE (
        'expression',
        FILTER (
            ALLSELECTED ( Table ),
            YEAR ( [Date] )
                >= YEAR ( selected ) - 9
                && YEAR ( [Date] ) <= YEAR ( selected )
        )
    )

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

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.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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