Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Hello to Everyone
I have two big problems for create a 2 different measures. The first one. I want calculate the distinct IDUser that are not prensent in my date range.
Here my data model
The join is Asset[IDassegnatario] with Soggetto[IDPersona]
I want obtain the number of distinct subjet that are not present inside the date range that i selected in the slicer. So if a subject compare inside the date range have to be exluded from the distinctcount.
I tried this dax code :
I
Solved! Go to Solution.
IdsInDateRange gets a list of IDassegnatario present inside the date range and uses TREATAS to move them back to the Soggetto dimension.
AllIds gets a list of all IDPersona. (Note if you removed the bidirectional filter the caclulate and removefilters wouldn't be needed).
IdsOutsideRange gets a list of all ids that are in AllIds but not in IdsInDateRange using EXCEPT.
It then just returns a count of these.
Hi sorry I posted earlier and then realised there was more complexity to the problem.
I think I've now fully understood and the following will help:
VAR LatestVisibleDate = MAX(Dwh_D_Tempo[Data]),
VAR EarliestVisibleDate = MIN(Dwh_D_Tempo[Data])
VAR IdsInDateRange =
TREATAS (
CALCULATETABLE (
VALUES ( Dwh_D_Asset[IDassegnatario] ),
Dwh_F_Asset[DataInizioValidita]<= LatestVisbleDate
Dwh_F_Asset[DataFineValidita] >= EarliestVisibleDate
),
Dwh_D_Soggetto[IDPersona]
)
VAR AllIds =
CALCULATETABLE (
VALUES ( Dwh_D_Soggetto[IDPersona] ),
REMOVEFILTERS ( Dwh_D_Soggetto )
)
VAR IdsOutsideRange =
EXCEPT (
AllIds,
IdsInDateRange
)
RETURN
COUNTROWS ( IdsOutsideRange )
IdsInDateRange gets a list of IDassegnatario present inside the date range and uses TREATAS to move them back to the Soggetto dimension.
AllIds gets a list of all IDPersona. (Note if you removed the bidirectional filter the caclulate and removefilters wouldn't be needed).
IdsOutsideRange gets a list of all ids that are in AllIds but not in IdsInDateRange using EXCEPT.
It then just returns a count of these.
@bcdobbs mate thank you so much really !!! It's really smooth your Dax formula i never saw and used the treatas formula, look like really massive.
I will remove the bideriction in order to have just :
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 7 | |
| 6 | |
| 4 | |
| 4 | |
| 4 |
| User | Count |
|---|---|
| 25 | |
| 17 | |
| 9 | |
| 8 | |
| 7 |