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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Distinct values with or statement

Hello everybody,

I have got a problem with using distinct values.

Some context:
I'm working with a dashboard where people can select a beginning and ending date with two slicers. I harvest these slicers into a measure (using values) , which i used to create Variables called dynamicbegin and dynamicend (which represents the beginning and end of the period that people choose on the dashboard).

Now I want to count the unique values of a column called  "Combinatie BSN & ZIN" (which has starting and end dates in the table it is from), for where OR the beginning OR the end is inside of the selected period (which is selected by user on dashboard).

I figured out a logic to do this. I first distinctcount all the values in column "Combinatie BSN & ZIN". Then i substract the values from that column of which the starting date is AFTER the ending date of the selected period OR where the ending date is BEFORE
the selected period. This measure is down below.

TESTING = 
VAR dynamicbegin = [Dynamisch begindatum] 
VAR dynamicend = [Dynamisch einddatum]

RETURN

CALCULATE(DISTINCTCOUNT('Data verstrekkingen'[combinatie BSN & ZIN]) 
-
CALCULATE(DISTINCTCOUNT('Data verstrekkingen'[combinatie BSN & ZIN]);
FILTER('Data verstrekkingen';'Data verstrekkingen'[Product begindatum]>dynamicend ||
'Data verstrekkingen'[Product einddatum] < dynamicbegin)))


This logic works perfeclty fine. I already double checked.

Except for the distinct values part. Because I use a or statement (the double pipe symbol "||") there are still duplicates. It unduplicates the part before and after the "||" symbol, but because of that there are still duplicates between those two groups, that are not made unique.

Is there a method to again distinct out all the values from the bottom part of the formula? So of this part.

CALCULATE(DISTINCTCOUNT('Data verstrekkingen'[combinatie BSN & ZIN]);
FILTER('Data verstrekkingen';'Data verstrekkingen'[Product begindatum]>dynamicend ||
'Data verstrekkingen'[Product einddatum] < dynamicbegin))

Or do I (instead of the or "||" statement ) have to split this specific part into two measures and then distinct out those two measures? (If yes how do i do this)


Would be very gratefull if someone has a sollution!

Greatings.

 

Lucas

3 REPLIES 3
v-frfei-msft
Community Support
Community Support

Hi @Anonymous,

 

How about using Or instead of ||? 

 

CALCULATE(DISTINCTCOUNT('Data verstrekkingen'[combinatie BSN & ZIN]);
FILTER('Data verstrekkingen';'OR(Data verstrekkingen'[Product begindatum]>dynamicend, 
'Data verstrekkingen'[Product einddatum] < dynamicbegin))

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
Anonymous
Not applicable

Thanks for your respons! I tried it, but sadly it does not work. It gives the same result as with the "||" symbol. Have you got any other suggestions?

Hi @Anonymous,

 

Could you please share your sample data and excepted result to me, if you don't have confidential data? Please upload your file to One Drive and share the link here.

 

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors