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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Anonymous
Not applicable

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

 

Anonymous
Not applicable

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.

Anonymous
Not applicable

Dear @johnt75 

 

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

 

timur_ptec_0-1676076869625.png

😞

 

 

hi @Anonymous 

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

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

Anonymous
Not applicable

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 @Anonymous 

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

 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.