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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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