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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
vagelis
Frequent Visitor

Need help with a calculated colum/measure which selects a date and all previous dates

I dont know if this is possible, but thanks for looking if you are able to help. I have a table which contains a column trans_ppyy, date is in format YYYYMM so 202305, 202304 etc, multiples of each as its transactions in a period. its based on a transactional table which should roll up and at the end there is a balance. I need a way that someone can select a specific period  so for example 202205 and my table filters to 202205 and ALL periods before, obviously filtering the table on 202205 will just give transactions in that period so the end balance doesnt match up. Cant figure it out, thanks

2 REPLIES 2
vagelis
Frequent Visitor

thanks for the suggestion but that doesnt work as a solution for my data, I want to give people the ability to select the data with a filter such as below which would then show them the cumulative data based on the selection they make in the trans_ppyy[yr_period] filter , I think my logic is right but doesnt give me the correct returns in the calc column

 

 

FilteredData =
VAR SelectedPeriod = MAX('trans_ppyy'[yr_period])
VAR CurrentPeriod = 'Period_End_Check'[trans_ppyy]
RETURN
    IF(
        CurrentPeriod <= SelectedPeriod,
        1,
        0
    )

 

 

 

johnt75
Super User
Super User

You can create a measure like

Balance =
VAR MaxDate =
    MAX ( 'Date'[Date] )
VAR Result =
    CALCULATE ( SUM ( 'Table'[Amount] ), 'Date'[Date] <= MaxDate )
RETURN
    Result

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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