Forum Discussion
Filtercontext with date relation
- 1 month ago
Hey, s_schultes ,
Your flag won't be filtered by department, and will send the result to every single department you have. This probably causes the overhelm of Direct Query.
Same also for customers that don't have a revenue or something:
You don't even need the flag. You can just build something like this, which will automatically not display anybody that doesn't have revenue or w/e you're after.
Neukunden Netto = CALCULATE( SUM(FactSales[geknetto]), USERELATIONSHIP( DimDate[Date], DimKunde[Anlagedatum] ) )
If you need to display customers by department, you can also do sometheing like this:Neukunde Flag Updated = CALCULATE( COUNTROWS(DimKunde), USERELATIONSHIP( DimDate[Date], DimKunde[Anlagedatum] ), TREATAS( VALUES(FactSales[KundeId]), DimKunde[Id]) )
Neukunden Gesamtnetto =
VAR IsNewCustomer =
CALCULATE(
COUNTROWS(DimKunde),
USERELATIONSHIP(DimDate[Date], DimKunde[Anlagedatum])
)
RETURN
IF(
IsNewCustomer > 0,
[Gesamtnetto],
BLANK()
)
- s_schultes1 month agoFrequent Visitor
Hi Parchitect ,
if I use your Dax and remove the flag from the filter context, I can select All from department....but it looks like the Date context is not really working. If i switch to department 43, there should be 42 customers...but I get way more. If I switch the department, the Ids are changing so I guess the time filter makes trouble at this point.
- Parchitect1 month agoSolution SageBefore changing the DAX or other changes further, I think we need to clarify one point because it changes the measure logic.Should the selected Year/Month filter only DimKunde[Anlagedatum] to identify new customers, or should it also filter FactSales[Datum] when calculating [Gesamtnetto]?For example, for Year = 2026 and Department = 43, you mentioned the expected result is 42 customers.Are those 42 customers:1. customers created in the selected period and having at least one FactSales row in department 43, regardless of sales date;or2. customers created in the selected period and having FactSales rows in department 43 within the same selected sales period?That distinction is important because the date table can affect DimKunde through USERELATIONSHIP, while department comes through FactSales. If both date paths are active in the calculation, the measure can return more or fewer customers than expected.I would also test this debug measure for Department 43:[Debug Intersection] =VAR NewCustomersByCreatedDate =CALCULATETABLE(VALUES(DimKunde[Id]),USERELATIONSHIP(DimDate[Date], DimKunde[Anlagedatum]))VAR CustomersWithBeleg =CALCULATETABLE(VALUES(FactSales[customerid]))VAR CustomersToShow =INTERSECT(NewCustomersByCreatedDate,CustomersWithBeleg)RETURNCOUNTROWS(CustomersToShow)Please replace FactSales[customerid] with your actual customer key column.If this returns 42 for Department 43, then the customer filtering logic is correct and we only need to adjust the value measure. If it returns more than 42, then the department/date filter is not intersecting with the customer set as expected.
- s_schultes1 month agoFrequent Visitor
Hi Parchitect ,
good Point, I was aiming to this solution you mentioned already:
2. customers created in the selected period and having FactSales rows in department 43 within the same selected sales period?
I tested the measure and it returns 42 in department 43. I used a similar measure for my card visual and diagramm.
Neukunden mit Beleg = CALCULATE( DISTINCTCOUNT(DimKunde[id]), USERELATIONSHIP(DimDate[Date], DimKunde[Anlagedatum]), TREATAS( VALUES(FactSales[KundeId]), DimKunde[id] ) )
- s_schultes1 month agoFrequent Visitor
Parchitect Hi, i will try it with the second dateTable.
But how should the relation work now?
I have DimDateKunde and DateKunde with a active Relation but if I make a relation with FactSales, this will be a inactive relationship. How should I handle this relation then?
- v-achippa1 month agoCommunity Support
Hi s_schultes,
Thank you for reaching out to Microsoft Fabric Community.
Here you don't need to connect the new date table to FactSales, just create an active relationship between DimDateKunde → DimKunde[Anlagedatum].
- DimDateKunde filters DimKunde by the customer creation date and your existing DimKunde → FactSales relationship carries that filter through to the sales table. Use DimDateKunde as the slicer for the new customer period and DimDate as the slicer for the sales period, this gives you two separate active date tables.
Thanks and regards,
Anjan Kumar Chippa