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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

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
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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

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.