web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Answered

Comparing chart between months

(0) ShareShare
ReportReport
Posted on by 411

Hello mates, 
I'm trying to make a chart who will compare this month of this year and the month of the last year : 

pastedimage1610820590616v1.png

I think i have succeeded to, but i need to display the Jan 2021 near the Jan 2020 column to make it more relevant, do you know if its possible please ? that would be great 

Best regards.

I have the same question (0)
  • Ana Pereira Profile Picture
    on at

    Hello,

    I found this blog that I believe can help you on your goal.

    crmchartguy.com/.../

  • Archetype Profile Picture
    411 on at

    Hello, thanks for your answer, unfortunately it doesnt work anymore for cloud versions :(

  • Community Member Profile Picture
    on at

    Hi Archetype,

    I find one way that the same writter provide, which using dataflow and power BI function to achieve goal, maybe you can refer it to test.

    https://crmchartguy.com/2020/03/31/compare-this-year-to-last-year-unified-interface-edition/ 

    Regards,

    Leah Ju

    Please mark as verified if the answer is helpful. Welcome to join hot discussions in Dynamics 365 Forums.

  • Archetype Profile Picture
    411 on at

    Hello, unfortunately we dont have power BI licenses

  • Community Member Profile Picture
    on at

    Hi Archetype,

    Through the Instruction from the link, the most import is that you can create two custom field to store year and month of date field, then use them to create chart.

    1.Create year and month field, then add then to the form and view you need.

    2.Add filter to the view if you just show records that last year and current year.

    you can use createdon date to set filter, i just test with custom date field.

     pastedimage1611115775212v1.png

    3.Create chart.

     pastedimage1611115809487v2.png

    4.Test.

     pastedimage1611115838370v3.png

    Note: you can use js code fill year and month field automatically.

    (1)js code.

    function SetMonth(executionContext) {
        var formContext = executionContext.getFormContext();
        var date = formContext.getAttribute("new_date").getValue();
        var d = new Date(date);
        locale = "en-us";
        var curr_year = d.getFullYear().toString();
        var curr_month = d.toLocaleString(locale, { month: "long" });
        formContext.getAttribute("new_month").setValue(curr_month);
        formContext.getAttribute("new_year").setValue(curr_year);
    }

    (2)Add js code to the OnSave event.

    Go to Settings > Customizations > Customize the system > Web Resource.

    pastedimage1611116038231v5.png

    Go to Settings > Customizations > Customize the system > Entities >one entity you need> Forms > main form to click ‘Form Porperties’ button to open one dialog.

    pastedimage1611115964701v4.png

    Regards,

    Leah Ju

    Please mark as verified if the answer is helpful. Welcome to join hot discussions in Dynamics 365 Forums.

  • Verified answer
    Community Member Profile Picture
    on at

    Hi Archetype

    And js code just for creating new records, not for large existing records.

    So you need use workflow or flow to extract year and month from date field, but no oob workflow function, you need download Date Time Workflow Utilities from Jason Lattimer.

    https://github.com/jlattimer/CRM-DateTime-Workflow-Utilities

    Download it and import it to the solution.

    pastedimage1611047506317v1.png   pastedimage1611047516678v2.png

    After importing the solution and open it to see the plugin name and remember it.

    pastedimage1611047731048v3.png

    Go Settings > Process to create an on-demand new workflow in the entity you need.

    pastedimage1611047823287v4.png

    Add steps, find plugin name and click it to select get month name  and get year number function.

    pastedimage1611048027701v5.png

    set their properties(you need add createdon field in the page).

    pastedimage1611048163994v6.png

    Add 'Update record', then lick 'set properties'to put year and month into the fields.

    pastedimage1611048194334v7.png pastedimage1611048531346v8.png

    Save and Active the workflow.

    Go to view page, select records you need and expand flow button to run the workflow you created.

    pastedimage1611048695188v9.png

    Regards,

    Leah Ju

    Please mark as verified if the answer is helpful. Welcome to join hot discussions in Dynamics 365 Forums.

  • Archetype Profile Picture
    411 on at

    Hello Leah Ju, thanks a lot for your answer. I'm sorry I really didnt understand what i have to do :( 

    My goal is to display a comparing chart between month of this year and month of last year in the milestone entity. 

    Actually i use this chart : 

    Legend = amount line --> Sum

    Catégorie = milestone date (Month) 

    pastedimage1611049067978v1.png

  • Verified answer
    Community Member Profile Picture
    on at

    Hi Archetype,

    Now, you can’t achieve it by customizing chart with xml and you don’t have power BI licenses to do second ways.

    So you can Imitate the second method to create two fields (Year and Month), then you can extract Year and Month from date field(milestone date) to fill into the new fields manually.

    pastedimage1611115151462v1.png

    Then you can use these two fields as horizontal(category) when you editing chart.

    pastedimage1611115230123v2.png

    if so, chart will show as you want: show same month with last and this year together.

    pastedimage1611115363380v3.png

    The js and workflow is used to fill new fields(Year and month) automatically, js can fill them  when you creating new records, and workflow can fill them in existing records.

    Finally, I replaced the previous screenshot with a clearer one in previous answer.

    Regards,

    Leah Ju

    Please mark as verified if the answer is helpful. Welcome to join hot discussions in Dynamics 365 Forums.

  • Archetype Profile Picture
    411 on at

    Hello Leah Ju,

    Thanks for you very much for your help, so in summary i have to do these steps : 

    1. I make 2 custom fields named "year" and "month" in milestones entity,  which type of format ? free text or whole number ? 

    2. I add these 2 custom fields that i have made to the main form and the view of milestone entity

    3. I create the chart , Legend entries : Sum of milestone amounts and Horizontal : year and month fields

    4. I add the js code on the OnSave event on the main milestone entity for the next new milestones

    5. To get the older existing milestones dates i have to download the solution and import it

    6. I set like you did a workflow and i run it 

    7. That's all

    8. After i run the workflow to retrieve the old records, can i delete it ? 

    Best regards and thanks a lot ;), you saved me a lot of times Leah , thanks you very very much

  • Verified answer
    Community Member Profile Picture
    on at

    Hi Archetype,

    The type of field i created is text, and you can delete workflow after updating original records.

    pastedimage1611654580006v1.png

    And other steps you understand are all right, you can try to test.

    Regards,

    Leah Ju

    Please mark as verified if the answer is helpful. Welcome to join hot discussions in Dynamics 365 Forums.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
Martin Dráb Profile Picture

Martin Dráb 41 Most Valuable Professional

#2
iampranjal Profile Picture

iampranjal 39

#3
Satyam Prakash Profile Picture

Satyam Prakash 35

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans