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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.