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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
codingenthu
Frequent Visitor

Creating a common YearMonth column in Power BI

Hi,

In Power BI, I'm working with a WorkStationAudit Table containing columns such as StartDate, EndDate, CreatedDate, ResolutionDate, and Issuekey. My aim is to generate a Line and Clustered Column chart, with the x-axis representing YearMonth and the y-axis showing the count of Issuekey. The chart should include two lines: Actual and Planned. The Actual(count of actual completed wsa cumulatively) line is derived from the ResolutionDate, while the Planned line(shows cumulatively over each month how many wsa are planned for the year) is based on the StartDate. However, I'm encountering difficulty in selecting the appropriate date for the x-axis. If I use StartDate, only the Actual line functions correctly; if I opt for ResolutionDate, only the Planned line is accurate.

Any ideas/Suggestions would help Thanks!

4 REPLIES 4
sjoerdvn
Super User
Super User

I think what you need is to have a single date (dimension) table and multiple relationships. Then, create measures with USERELATIONSHIP. Checkout https://learn.microsoft.com/en-us/dax/userelationship-function-dax

 

v-yohua-msft
Community Support
Community Support

Hi, @codingenthu 

Based on your information, I create a sample data table:

vyohuamsft_0-1715755924813.png

 

Create a calculated column :

YearMonth = FORMAT('Table'[StartDate], "YYYY-MM")

vyohuamsft_1-1715756106533.png

 

Then create two measures :

Actual Count = CALCULATE(SUM('Table'[Issuekey]), FILTER(ALL('Table'), 'Table'[ResolutionDate] <= MAX('Table'[ResolutionDate])))

Planned Count = CALCULATE(SUM('Table'[Issuekey]), FILTER(ALL('Table'), 'Table'[StartDate] <= MAX('Table'[StartDate])))

 

Here is my preview:

vyohuamsft_2-1715756222628.png

 

How to Get Your Question Answered Quickly 

Best Regards

Yongkang Hua

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

@v-yohua-msft Thank you for the reply!!

Actually in the visual i want to see both Actual and Planned Lines. So what i was trying to say is If i create YearMonth column based on StartDate then only Planned Line seems working as we have used StartDate in the Planned Line and Actual Line seems doesn't working.

Greg_Deckler
Super User
Super User

@codingenthu Sorry, having trouble following, can you post sample data as text and expected output?
Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.


Follow on LinkedIn
@ 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
July 2024 Power BI Update

Power BI Monthly Update - July 2024

Check out the July 2024 Power BI update to learn about new features.

July Newsletter

Fabric Community Update - July 2024

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

Top Solution Authors