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
Anonymous
Not applicable

Parse a slicer through a DAX command

Hey folks,

I am trying to parse a slicer though a DAX command and what I have tried so far hasn't work thus I would appreciate any help on this.

 

I have a "CALCULATE" command in a formula that looks like this

'

Baseline = CALCULATE(COUNTA('NewTable'[ID]),
filter(NewTable,NewTable[Base].[Date]=newesttable[End Time].[Date]
&&
CONTAINSSTRING(NewTable[Group], "*Attribute1*") = TRUE())
)
The current way I build this report is I create a new table for every "Atrribute1" and replace with appropriate attribute. Attribute1 is a string variable.
A new request was made for a slicer, especially as said report should contain 80 different attributes!!
 
The approach adopted so far has been to create a measure. The measure calculation is measure2 =SelectedValue(Attributes).
 
I have tried the following, but got no result.
1.
Baseline = CALCULATE(COUNTA('NewTable'[ID]),
filter(NewTable,NewTable[Base].[Date]=newesttable[End Time].[Date]
&&
CONTAINSSTRING(NewTable[Group], measure2) = TRUE())
)
 
2. I also tried this:
var val=SELECTEDVALUE(NewTable[CREWGROUP])
return
CALCULATE(COUNTA('NewTable'[ID]),
filter(NewTable,NewTable[Base].[Date]=newesttable[End Time].[Date]
&& 
NewTable[GROUP] = val).
 
Option 1 pretty much attempts to make the dax formular reference the measure, while option 2 tries to make the dax formular reference the selection on the page. But have been unsuccessful.
 
Any recommendation of a better way of doing this? A way to make a DAX command harvest the selection on a slicer?
 
Thanks.
 
1 REPLY 1
lbendlin
Super User
Super User

You may be overcomplicating things.  Use the FILTERS() function, and then INTERSECT() etc as needed.

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.

Top Solution Authors