Forum Discussion
Sharing a temporary table between measures
- 3 years ago
The answer is No and Yes
No ... you can not crate a measure in one measure and use it in another. âšī¸âšī¸
But ... yes ... I have a solution to your 50 second problem đđ
Click here to download the solution
How it works ...
First use Enter Data to manaully create a driver table with the names of your 8 meaures
For example her are 6 ...
Then create a DAX measure which uses VAR to build your temp table once.
Note it is much faster to aggergate using ADDCOLUMNS rather that SUMMARIZEThen use SWITCH to reuse the temp table 8 times.
Dynamic =VAR salesbycountry = ADDCOLUMNS(VALUES(Customers[Country]),"CSales",[Total Sales],"CCosts",[Total Costs],"CTax",[Total Tax])
RETURN
SWITCH(SELECTEDVALUE(Driver[ID]),1, SUMX(salesbycountry,[CSales]),2, SUMX(salesbycountry,[CSales] + [CTax]),3, SUMX(salesbycountry,[CSales] - [CCosts]))For example this DAX meassure creates salesbycountry temp table.
Then uses salesbycountry to create lossbycountry and profitbycountry temp tables.
Then uses SWITCH to create 6 measure.
This method can easily reduce 90 seconds masures to under 5 seconds.
Please let me know how you get on.
Filtered =VAR salesbycountry = ADDCOLUMNS(VALUES(Customers[Country]),"CSales",[Total Sales],"CCosts",[Total Costs],"CTax",[Total Tax])VAR lossbycountry = FILTER(salesbycountry,[CCosts] > [CSales])VAR profitbycountry = FILTER(salesbycountry,[CSales] >= [CCosts])
RETURN
SWITCH(SELECTEDVALUE(Driver[ID]),1, SUMX(lossbycountry,[CSales]),2, SUMX(lossbycountry,[CSales] + [CTax]),3, SUMX(lossbycountry,[CSales] - [CCosts]),4, SUMX(profitbycountry,[CSales]),5, SUMX(profitbycountry,[CSales] + [CTax]),6, SUMX(profitbycountry,[CSales] - [CCosts]))Thanks for reaching out for help.
I put in a lot of effort to help you, now please quickly help me by giving kudos.
Remember we are unpaid volunteers and here to coach you with Power BI and DAX skills and techniques, not do the users job for them. So please click the thumbs up and accept as solution button.
If you give someone a fish then you only give them one meal, but if you teach them how to fish then they can feed themselves and teach others for a lifetime. I prefer to teach members on this forum techniques rather give full solutions and do their job. You can then adapt the technique for your solution, learn some DAX skills for next time and soon become a Power BI Super User like me.
One question per ticket please. If you need to extend your request then please raise a new ticket.
You will get a quicker response and each volunteer solver will get the kudos they deserve. Thank you !
The answer is No and Yes
No ... you can not crate a measure in one measure and use it in another. âšī¸âšī¸
But ... yes ... I have a solution to your 50 second problem đđ
Click here to download the solution
How it works ...
First use Enter Data to manaully create a driver table with the names of your 8 meaures
For example her are 6 ...
Then create a DAX measure which uses VAR to build your temp table once.
Note it is much faster to aggergate using ADDCOLUMNS rather that SUMMARIZE
Then use SWITCH to reuse the temp table 8 times.
For example this DAX meassure creates salesbycountry temp table.
Then uses salesbycountry to create lossbycountry and profitbycountry temp tables.
Then uses SWITCH to create 6 measure.
This method can easily reduce 90 seconds masures to under 5 seconds.
Please let me know how you get on.
Thanks for reaching out for help.
I put in a lot of effort to help you, now please quickly help me by giving kudos.
Remember we are unpaid volunteers and here to coach you with Power BI and DAX skills and techniques, not do the users job for them. So please click the thumbs up and accept as solution button.
If you give someone a fish then you only give them one meal, but if you teach them how to fish then they can feed themselves and teach others for a lifetime. I prefer to teach members on this forum techniques rather give full solutions and do their job. You can then adapt the technique for your solution, learn some DAX skills for next time and soon become a Power BI Super User like me.
One question per ticket please. If you need to extend your request then please raise a new ticket.
You will get a quicker response and each volunteer solver will get the kudos they deserve. Thank you !