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
djreyes
Helper I
Helper I

Year Computation

Hello, 

I have a measure added in powerbi = ([QTY negative to positive max per item]*3)/365*([average qty]*1.2)

How do I make the 365 change that when they select a year filter it will become 730 if they selected 2018 to 2019, if they selected 2018-2019 it will become 1095 and so and so forth. 

 

I am not really sure how to do it. I have a transaction date column from 2018-2024 but its dynamic that it will refresh everyday so I need to consider that after 2024, new data from 2025 will be added.

 

Thank you so much!

 

1 ACCEPTED SOLUTION

Right, it should autometically come into slicer and hence in report.

If this resolves your problem, then please mark this as solution, Thanks!

View solution in original post

6 REPLIES 6
djreyes
Helper I
Helper I

@samratpbi @lbendlin I did try it but when I filter 2018-2021 its showing 5 years instead of 4, how will i do the year multiply, it should be by days and not by year.

 

djreyes_0-1713478169694.png

 

Hi, if you want to return no of years when selected, you can simply remove the + 1 in the measure. I thought you would need 730 if 1 year selected. Hence there is a + 1 with count years.

Thank you so much! It works now, last question, so if a new year is added I dont need to do anything right?

djreyes_0-1713478979470.png

 

Right, it should autometically come into slicer and hence in report.

If this resolves your problem, then please mark this as solution, Thanks!

lbendlin
Super User
Super User

Don't use fixed numbers.  Have a calendar table in your data model and count the date rows for your selected years.

samratpbi
Solution Supplier
Solution Supplier

Hi, lets create a slicer on the years which you are going to select then create a measure below:

Years Selected =
IF(
    NOT(ISFILTERED(DynCol[Year])),
    1,
    COUNTROWS(
        SUMMARIZE(
            DynCol,
            DynCol[Year]
        )
    ) + 1
)
what it will do is, if no year selected, then it would return 1, otherwise it would return no of years selected + 1, i.e. if 1 year selected it would return 2 and so on.
now, you simply multiply this measure with 365 in your existing measure.
Below is the result:
when no year selected:
samratpbi_0-1713477556333.png

when 1 year selected:

samratpbi_1-1713477585516.png

Hope this resolves your problem,

If this helps to resolve your problem then please mark it as solution, Thanks!

Helpful resources

Announcements
Fabcon_Europe_Social_Bogo

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.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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