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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
timur_ptec
New Member

Filter first 12 month data from each Unique Data

Hi All

I have huge data set available and would like to filter for FIRST 12 month of each Unique data. Date for each Unique Data may start at different dates but i need to plot first 12 month of each Unique Data. 

 

I have following Columns:

"Unique Data" , "Date", "Value"

 

Can someone help me with this?

 

Thanks

Regards

Timur

 

 

7 REPLIES 7
johnt75
Super User
Super User

You could create a table to store the dates for each item, e.g.

Start and end dates =
GENERATE (
    DISTINCT ( 'Table'[Unique ID] ),
    VAR StartDate =
        CALCULATE ( MIN ( 'Table'[Date] ) )
    VAR EndDate =
        EOMONTH ( StartDate, 12 )
    RETURN
        ROW ( "Start Date", StartDate, "End Date", EndDate )
)

and then link this to your fact table. If you already have a dimension table you could just add the start and end date columns to that.

You can then create a measure like

First 12 months data =
SUMX (
    'Dim table',
    VAR StartDate = 'Start and end dates'[Start Date]
    VAR EndDate = 'Start and end dates'[End date]
    RETURN
        CALCULATE (
            SUM ( 'Table'[value] ),
            KEEPFILTERS ( DATESBETWEEN ( 'Date'[Date], StartDate, EndDate ) )
        )
)

 

Hi @johnt75 

 

Thanks for your prompt reply. But i am still having some issues with above code:

 

timur_ptec_0-1675984218907.png

 

It says cannot convert to a scalar value. Can you please let me know how to fix it?

 

Many thanks

 

Are you trying to create that as a measure? Because it needs to be a table not a measure.

Dear @johnt75 

 

I have created "New Column" using this code and still saying cannot convert scalar value

 

timur_ptec_0-1676076869625.png

😞

 

 

hi @timur_ptec 

the code is to create a new table, not a new column

Screenshot_2023-02-11-10-04-53-68_c10f17a1a5a2fddb73e7f14650890b8a.jpg

Dear @FreemanZ 

 

Thank you for your response. I have managed successfuly create a table but now when trying to link to main table via "new measures", there is following error message:

 

timur_ptec_0-1676082086174.png

is there any steps i am missing?

hi @timur_ptec 

you have too much unmentioned tables, describe your case clearly. 

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.