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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
benabdillahr
Frequent Visitor

DAX ALLEXCEPT function with RELATED table columns as filters

Hi All,

I am trying to calculate the distinct count of a field "Visits" but only need it to be filtreable by a "Date" field from another table.
I used the ALLEXCEPT funtion but the filter and formula only work when the "Date" field from the same table, when I use the "Date" field from the "Date" table, it doesn't work. 

Same Table Formula:

Total visits = CALCULATE( DISTINCTCOUNT(Visits[Visits: Visits Id]),
ALLEXCEPT(Visits, Visits[Date]))
benabdillahr_1-1637371691046.png

 

Related Tables Formula:
Total visits = CALCULATE( DISTINCTCOUNT(Visits[Visits: Visits Id]),
ALLEXCEPT('Date','Date'[Date])

 

benabdillahr_2-1637371708053.png


Thanks,



9 REPLIES 9
v-yanjiang-msft
Community Support
Community Support

Hi @benabdillahr ,

According to your description, here's my solution.

vkalyjmsft_0-1637662651814.png

Best Regards,
Community Support Team _ kalyj

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

smpa01
Super User
Super User

@benabdillahr may be try this

 

 

CALCULATE( DISTINCTCOUNT(Visits[Visits: Visits Id]),
ALL('Date'),VALUES('Date'[Date]), ALL(Visits[Category]))

replicated on a small scale, pbix is attached

 

 

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

Unfortunately, I get the same result ☹️

benabdillahr_0-1637600092827.png

 

@benabdillahr  please provide a sample pbix representative of the issue

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

Hi @smpa01 !

Here is exactly what I'm looking for, i just need the date filter to come from the date table instead of the visits table.

 

@benabdillahr  please check page2

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

@benabdillahr  did you have a chance to look into the solution I provided?

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
smpa01
Super User
Super User

@benabdillahr can you test out if this works for you

CALCULATE( DISTINCTCOUNT(Visits[Visits: Visits Id]),

ALL('Date'),VALUES('Date'[Date]))

 

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

Thank you @smpa01 for you response!
I tried your formula, the date filter from the related table is now working but it calculates the distinct count of visits by category. I want my measure to ignore the categories in order to have the same value "243" repeated for each category since I'm using it as a denominator for another measure.

benabdillahr_0-1637591540080.png

Thanks!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.