Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

how to create a table with calculation and column

I am a new DAX user, I want to konw that how to create a table to make a calculation and a dimension column, the new table should also consider the context, for example create a calculation that show the minmium day of expected_report_date column from original table and a new column with month number of  the previous month,for examle two value in  expected_report_dateis '1/5/2022' and '3/5/2022', the new table I want is:

min_date         previous_month

1/5/2022           4

 

 

1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Hi  @Anonymous ,

I created some data:

vyangliumsft_0-1653661699937.png

Here are the steps you can follow:

1. Create calculated column.

Month = YEAR('Table'[Sorted_onboard_date])&""&FORMAT('Table'[Sorted_onboard_date],"mm")
sum(request_headcount) =
SUMX(FILTER(ALL('Table'),'Table'[Month]=EARLIER('Table'[Month])),[request_headcount])

2. Create calculated table.

Table 2 =
SUMMARIZE('Table','Table'[Month],'Table'[sum(request_headcount)])

3. Result:

vyangliumsft_1-1653661699939.png

If you need pbix, please click here.

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

3 REPLIES 3
v-yangliu-msft
Community Support
Community Support

Hi  @Anonymous ,

I created some data:

vyangliumsft_0-1653661699937.png

Here are the steps you can follow:

1. Create calculated column.

Month = YEAR('Table'[Sorted_onboard_date])&""&FORMAT('Table'[Sorted_onboard_date],"mm")
sum(request_headcount) =
SUMX(FILTER(ALL('Table'),'Table'[Month]=EARLIER('Table'[Month])),[request_headcount])

2. Create calculated table.

Table 2 =
SUMMARIZE('Table','Table'[Month],'Table'[sum(request_headcount)])

3. Result:

vyangliumsft_1-1653661699939.png

If you need pbix, please click here.

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

amitchandak
Super User
Super User

@Anonymous , You can datediff of the two date in a new column

 

datediff([Date1],[Date2], day)

 

If this does not help
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

 

Anonymous
Not applicable

thanks, the requirement is need to add two fileds not one field, or may be a new table to be created

null_0-1653374288354.png

here is the original data,

I need  two column: sum(request_headcount) when month(sorted_onboard_date) = 202205 and 202205,

sum(request_headcount) when month(sorted_onboard_date) = 202204 ,202204

sum(request_headcount) when month(sorted_onboard_date) = 202205 ,202203

namely, I need to three values based on month(today) and return 2 columns to be shown to creat a visual:

month, sum(request_headcount)

202205           13

202204          23

202203          16

 

 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.