cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
PeterChen Regular Visitor
Regular Visitor

plot date for year and quarter without add up all values

Hi, 

I have a data and want to plot the line chart with year and quarter on x-axis.

There is a column called "date".

 

image.png

 

 

 

 

 

 

 

 

 

 

I create a measure and want to plot this measure.

REALWANT = 
VAR MINYR = CALCULATE(MIN(dt[date].[Year]),ALLEXCEPT(dt,dt[Group])) 
VAR MINQR = CALCULATE(MIN(dt[date].[QuarterNo]),ALLEXCEPT(dt,dt[Group])) 
VAR NEW= CALCULATE(SUM(dt[Numbers]), FILTER(ALLEXCEPT(dt,dt[Group]), dt[date].[Year] = MINYR && dt[date].[QuarterNo] = MINQR)) 
VAR WANTDenominator = IF(MAX(dt[Numbers]) = Blank(), Blank(), [NEW]) 
VAR WANTNominator = CALCULATE(SUM(dt[Numbers]), ALLEXCEPT(dt,dt[Group],dt[date].[Year],dt[date].[QuarterNo])) 
Return
WANTNominator/WANTDenominator 

Now, I click on the Line Chart in the report tab and put this measure on y-axis, Group on legend, and date hierarchy (only year and quarter) on x-axis.

However, the line plot showd inappropriately. On the x-axis, it only showed year so that it automatically added up measure for all quarters in each year by group.

 

Even I create a new column as below:

yq = dt[date].[Year] & dt[date].[QuarterNo]

And plot again, the x-axis on plot displays weired. It did not display as order.

 

How can I figure out this?

 

Also, is it possible to create a filter for Group and when I filter values in that, the plot will change. I think I need to add something like SELECTEDVALUE. Not sure.

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: plot date for year and quarter without add up all values

Hi @PeterChen ,

 

Based on my test, I got this output, Then what is your excepted result?

 

Capture.PNG

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

2 REPLIES 2
Community Support Team
Community Support Team

Re: plot date for year and quarter without add up all values

Hi @PeterChen ,

 

Based on my test, I got this output, Then what is your excepted result?

 

Capture.PNG

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

PeterChen Regular Visitor
Regular Visitor

Re: plot date for year and quarter without add up all values

 


@v-frfei-msft wrote:

Hi @PeterChen ,

 

Based on my test, I got this output, Then what is your excepted result?

 

Capture.PNG

 



Untitled.png

 

The order is weird if I create a new column with year and quarter.

Moreover, if I plot like your way using original date column and select hierarchy for year and quarter, the x-axis on line chart only shows year rather year and quarter.

 

In addition, if I copy your plot and then change the axis, legend, and values to my data, it works. Not sure why it works in copy and paste....

Helpful resources

Announcements
Exclusive LIVE Community Event #3 – Ask Arun Anything

Exclusive LIVE Community Event #3 – Ask Arun Anything

Join us in the third Triple A event!

Meet the 2020 Season 1 Power BI Super Users!

Meet the 2020 Season 1 Power BI Super Users!

It’s the start of a new Super User season! Learn all about the new Super Users and brand-new tiered recognition system.

January 2020 Community Highlights

January 2020 Community Highlights

Make sure you didn't miss any of the things that happened in the community in January!

Top Solution Authors
Top Kudoed Authors