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
Ian_Altis
Advocate III
Advocate III

Creating a table in DAX using a fliter

I am sure there is a way to do this but I am pulling my hair out!

 

As a DAX table expression this works (returns expected number of rows):

Filtered Fact = FILTER(Fact_Event,Fact_Event[Dim_Student_Key] = 12071)

 
Whereas this doesn't (does not filter rows at all):
Filtered Fact = FILTER(Fact_Event,Fact_Event[Dim_Student_Key] = [Selected Student Key])
 
[Selected Student Key] evaluates to 12071 and is an integer.
 
What am I doing wrong?
7 REPLIES 7
Ian_Altis
Advocate III
Advocate III

and [Selected Student Key] is a measure

@Ian_Altis what is the expression of [Selected Student Key] measure



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@parry2k  here you go: 

Selected Student Key = SELECTEDVALUE(Dim_Student[Dim_Student_Key])

@Ian_Altis so your fact doesn't have relationship with Dim_Student?? if yes then why you need to filter, once you filter dim student it will filter fact table?

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@Ian_Altis sorry read your post again, seems like you are trying to create a table with filtered student, unfortunately you cannot pass slicer value to when creating table using DAX and that is the reason your first expression works and 2nd one doesn't.

 

So question here is why you need a table?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Thanks again @parry2k The user wants to be able to fliter Dim_Student from attributes that are in Dim_Course.  There is no direct relationship between these two tables but there is Fact_Event in between.  One to many relationships from dims to the fact and single filter direction.rELATIONSHIPSrELATIONSHIPS

 

The filters (which they want on the filter pane) should only show those Dim_Course rows for which there are associated Dim_Student events.  Make sense?

 

Creating this filtered fact table was my idea of a step along the journey to create a filtered Dim_Course table that I could use in the filter.

 

I suspect there is a better way!!

 

So if I was able to do this in SQL (which I can write :-)) it would look something like this:

 

SELECT
Course_Code,
Mode_Of_Study
FROM Dim_Course c
INNER JOIN Fact_Event e
ON c.Dim_Course_Key = e.Dim_Course_Key
WHERE e.Dim_Student_Key = @Selected_Student_Key

 

I suspect I need to use crossfiltering or something but I bascically need a dynamic table that I can use as the source for a filter.

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