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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

April Fabric Community Update

Fabric Community Update - April 2024

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