cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
null
Helper V
Helper V

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  @null ,

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  @null ,

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

@null , 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.

 



Power BI Features || Datamarts: https://youtu.be/8tskWsJTEpg || Field Parameters : https://youtu.be/lqF3Wa1FllE?t=70
Time Intelligence Decoded : https://youtu.be/aU2aKbnHuWs&t=145s
Did I answer your question? Mark my post as a solution! Appreciate your Kudos !! Proud to be a Super User! !!
Dashboard of My Blogs !! Connect on Linkedin !! Subscribe to my youtube Channel !!
Want To Learn Power BI | Beginners !! Advance Concepts !! Power BI For Tableau User !!

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
August 2022 update 768x460.jpg

Check it Out!

Click here to learn more about the August 2022 updates!

August 1 episode 9_no_dates 768x460.jpg

The Power BI Community Show

Watch the playback when Priya Sathy and Charles Webb discuss Datamarts! Kelly also shares Power BI Community updates.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Top Solution Authors
Top Kudoed Authors