Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register 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 :
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
15 | |
11 | |
11 | |
10 | |
10 |
User | Count |
---|---|
19 | |
14 | |
13 | |
11 | |
8 |