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

Export the result of dax as a new table

Hi 

 

I have some data and I have built many DAX measures for different analysis on them. I want to export the results of my measures into a new table in a monthly basis. The following is a simple working example:

 

raw data

 

datesale
2020-01-151
2020-01-195
2020-01-212
2020-01-294
2020-02-012
2020-02-042
2020-02-063
2020-02-145
2020-02-191
2020-02-252
2020-03-016
2020-03-051
2020-03-104
2020-03-205
2020-03-252
2020-04-013
2020-04-102
2020-04-154
2020-04-192
2020-04-259

 

Now, imagine I have a DAX measure to sum sale per month (SUM(raw[sale]). I want to output the result of this measure into a new table and each row represents one month (for example start of month is good for me):

 

output table

 

start of monthsum of sale
2020-01-0112
2020-02-0115
2020-03-0118
2020-04-0120

 

All the measures that I want to examine on a monthly basis can then be added to each column of this table.

 

How can I do such export into a new table?

Thanks.

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , Please find the pbix with date table  . Table 2 ( From Table and Date)

View solution in original post

7 REPLIES 7
v-shex-msft
Community Support
Community Support

Hi @Anonymous,

You can use summarize function to aggregate table values based on specific categories, then you can get a new table that summer raw value based on raw category.

Then you can mapping the new table and raw table field based on the category, raw table measure expressions can use with new table fields and calculated based on the relationship mapping.

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
amitchandak
Super User
Super User

@Anonymous , Please find the pbix with date table  . Table 2 ( From Table and Date)

Anonymous
Not applicable

@amitchandak 

 

Thanks a lot. 

That works perfectly with the simple SUM measure.

 

In my own project, I am working with more complicated DAX. For example, I want to measure cumulative sum for each month. That is not working properly.

Do you have any idea how to do that?

Thanks.

@Anonymous , in file in last update. Table 2 ( From Table and Date) 

amitchandak
Super User
Super User

@Anonymous , Try new table

 

 

SUMMARIZE(SELECTCOLUMNS('Table',"Month" , EOMONTH('Table'[date],-1)+1 , "Sales",SUM('Table'[sale])),[Month],"sales",SUM('Table'[sale]))

 

or

Try two table

 

Table 3 = SELECTCOLUMNS('Table',"Month", EOMONTH([date],-1)+1, "sale",'Table'[sale])

Table 4 = SUMMARIZE('Table 3','Table 3'[Month],"sales",SUM('Table 3'[sale]))

 

 

 

Anonymous
Not applicable

Thanks @amitchandak 

 

Unfortunately, you dax for creating new table are actually not working.

 

mah65_4-1614741766702.png

 

 

mah65_3-1614741721235.png

 

So, I have to use this to create a new table. Right? Can you please provide some explanations with your solution?!

Also, can you please test them, preferrably in a power bi file?!

 

I also have to add that I have another table "Calendar" that has already the column "Start of Month". So, I can probably use it, but I don't know how exactly. I tried it in your equations above, but did not work.

 

Thanks.

@Anonymous , I have actually posted the revised answer, after testing, This option was working perfectly 

Try two table

 

Table 3 = SELECTCOLUMNS('Table',"Month", EOMONTH([date],-1)+1, "sale",'Table'[sale])

Table 4 = SUMMARIZE('Table 3','Table 3'[Month],"sales",SUM('Table 3'[sale]))

 

Two tables one after another. I will check one with date table. That should work with only summarize. if tables are joined 

 

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.