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
anonymous15
New Member

Creating a table through DAX

Hi guys, I  have recently started working with Power BI and I need some help with a problem that I'm facing.

 

I am trying to create a table which is going to select some values. Below is the expression for that

 

TemporaryTable =
VAR SelectedLeafMatch = [MatchedLeaf] // this is another dax measure that I have created
RETURN
        CALCULATETABLE( SUMMARIZE (
        'CALCULATIONS',
        'CALCULATIONS'[PROJECT_NAME],'CALCULATIONS'[PROJECT_NUMBER]),'CALCULATIONS'[LEAF_ID]= SelectedLeafMatch)
 
This expression is working well when I'm hardcoding the SelectedLeafMatch but when I'm passing the MatchedLeaf then it is not working
1 ACCEPTED SOLUTION

@anonymous15 You can use a VAR to store a dynamic, calculated table within a measure. Unfortunately you have to do that in every measure where you want the table because measures can't return tables.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

3 REPLIES 3
anonymous15
New Member

thanks for you reply @Greg_Deckler ..I do need to calculate a dynamic table. To provide further context, I'm using two filters and as users select values from the filter, [MatchedLeaf] calculates a value based on these filters and returns a value. I need to pass this value to 'CALCULATIONS'[LEAF_ID] to return selected values from the table. The idea is to use this table to perform further calculatons. In simple terms, I want the table to return values evrytime user makes a selection. Is there a way I can achieve this? Dynamic table is the only solution that I can see but is there anything else that can be done? Even for dynamic I'm not able to figure out a way as it's not working with varible, though it works when I hardcode the value.

@anonymous15 You can use a VAR to store a dynamic, calculated table within a measure. Unfortunately you have to do that in every measure where you want the table because measures can't return tables.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Greg_Deckler
Super User
Super User

@anonymous15 Mixing measures with calculated columns and tables almost never works. This is because measures are dynamic while calculated tables and columns are only calculated when refreshing data (generally). If you need a dynamic table, you can calculate the table and assign it to a VAR within a measure.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.