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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Foxxon28
Helper I
Helper I

Combine measure and keep filter context

Dear reader,

 

I have one base measure that I want to use for a lot of other measure, as it includes a certain logic that is needed for the whole report:

 

Dynamic Sales =

VAR MaxSelectedMonth =
                                SWITCH(
    TRUE(),
    ISFILTERED(Table[Source]) &&({"TV"} in VALUES(Table[Source])), MIN(MaxPeriodSource[Max_Period]),
    NOT(ISFILTERED(Table[Source])), MIN(MaxPeriodSource[Max_Period]),
    MAX(MaxPeriodSource[Max_Period])
)
RETURN

CALCULATE(
        SUM(
            Fact[Sales]), FILTER(Fact, Fact[Date] <= MaxSelectedMonth))
           
 
This measure calculates the [Sales] up untill the MAX [Date] from each [Source].
Dimention[Source] 1-* Fact
MAxPeriodSource = Disconnected table with distinct [Source] and MAX [Date] from fact.
 
 
The other measure I want to use is:
 
Sales Cumulative =
CALCULATE (
    [Dynamic Sales],
    FILTER (
        ALL(  fact[Month] ),
        Fact[Month] <= MAX ( fact[Month] )
    ))

 

This is a measure that should calcualte a cumulative sum based on Fact[Month]. However, it doesn't seem to include the filter logic from the [Dynamic Sales] measure. 

 

How could I combine these 2 measure, so that I basically create [Dynamic Sales] with the cumulative sales logic from [Sales Cumulative]

 

 

Would like to hear from you!

Daniël

1 REPLY 1
DataNinja777
Super User
Super User

Hi @Foxxon28 ,

My initial observation on you dax formula is that you are filtering your fact table date field using the fact table instead of the calendar dimension table.  Is there any reason why date field from your fact table should be used as the filter instead of the date field from your calendar table?  In Power BI, it is recommended to have a star schema data model where you have the fact tables and dimension tables (such as the calendar table), and the date field in your calendar table should be used for filtering so that multiple fact tables can be filtered whilst keeping them as  separate tables.

Best regards,

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.

Top Solution Authors