Skip to main content

Notifications

Announcements

No record found.

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.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Comparing chart between months

    Hi,

    Yes, you need change attribute with your fields logic name.

    pastedimage1612171658140v1.png

    Regards,

    Leah Ju

  • Archetype Profile Picture
    Archetype 411 on at
    RE: Comparing chart between months

    Hello Leah Ju,


    I will try it tonight because our sandbox environnement was down, just a last question please , have i to modify your JS code by replacing something to match with my milestone entity please?

    Best regards

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Comparing chart between months

    Hi Partner,

    Has the problem been solved? Any updates?

    Please click Yes under "Did this answer your question?" to close this thread.

     pastedimage1611713758428v1.png

    Thanks. 

    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
    Community Member Microsoft Employee on at
    RE: Comparing chart between months

    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.

  • Archetype Profile Picture
    Archetype 411 on at
    RE: Comparing chart between months

    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
    Community Member Microsoft Employee on at
    RE: Comparing chart between months

    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
    Archetype 411 on at
    RE: Comparing chart between months

    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
    Community Member Microsoft Employee on at
    RE: Comparing chart between months

    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.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Comparing chart between months

    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.

  • Archetype Profile Picture
    Archetype 411 on at
    RE: Comparing chart between months

    Hello, unfortunately we dont have power BI licenses

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

Congratulations 2024 Spotlight Honorees!

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December!

Congratulations to our December super stars! 🥳

Get Started Blogging in the Community

Hosted or syndicated blogging is available! ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,622 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,354 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans