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

Display Month-wise and YTD data in one visual

Hi Guys,

 

I am trying to display month-wise and  YTD data in one visual, which I am not able to do it now. Is there any provision to do this in Power BI?

I have attached a sample snapshot with this, that I want to achieve in power BI. Please suggest any visual if any or DAX.

Sample graphSample graph

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

Hi @Anonymous ,

 

Please check the following steps as below.

 

1. Create a calculated table and relat it to the fact table like this.

YM = UNION(VALUES('Table'[Year]),VALUES('Table'[Month]))

Capture.PNG

 

2. Then we can create a measure to get the excepted result as we need.

 

Measure = var a = SUM('Table'[value])
return
IF(ISBLANK(a),CALCULATE(SUM('Table'[value]),USERELATIONSHIP('Table'[Year],YM[Year])),a)

2.PNG

 

For more details, please check the pbix as attached.

 

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

8 REPLIES 8
v-frfei-msft
Community Support
Community Support

Hi @Anonymous ,

 

Please check the following steps as below.

 

1. Create a calculated table and relat it to the fact table like this.

YM = UNION(VALUES('Table'[Year]),VALUES('Table'[Month]))

Capture.PNG

 

2. Then we can create a measure to get the excepted result as we need.

 

Measure = var a = SUM('Table'[value])
return
IF(ISBLANK(a),CALCULATE(SUM('Table'[value]),USERELATIONSHIP('Table'[Year],YM[Year])),a)

2.PNG

 

For more details, please check the pbix as attached.

 

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

 

This solution works excellent, How i can sort the months chronologically? Jan, Feb, Mar, Apr, .........YTD

 

tks.

 

Anonymous
Not applicable

Thank you for the solution. It worked for me.

Minseven
Helper I
Helper I

I don't get your question.

 

Put the "YEAR" in the Legend dimension

RobbeVL
Impactful Individual
Impactful Individual

Hi,

 

You'll be able to use this DAX measure:
SAMEPERIODLASTYEAR()
https://docs.microsoft.com/en-us/dax/sameperiodlastyear-function-dax 

just do ex.
CALCULATE(SUM(SALES); SAMEPERIODLASTYEAR(DATE))

 

And you should have a measure with the data from last year.

 

Robbe

Anonymous
Not applicable

Thanks

We have already used that DAX, but it is not working.

What I want is one bar for past year and for this year(i.e 2019), the graph should show month-wise, this both(past year and 2019 month-wise) in one graph as shown in the screenshot.

 

Anonymous
Not applicable

 

I am able to do it in excel, need solution to implement same in Power BIsample.jpg

RobbeVL
Impactful Individual
Impactful Individual

Hi,

DataViz wise, you really created a monster here.

Any specific reason why you would do it like this?

 

For doing this you should create a custom table that would precalculate all values you need. 

robbe

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.