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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

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
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.