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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Sac
Helper I
Helper I

How to Calculate sales by month

Id    Sale           Date

1      $5               01/02/2017

2      $6              01/02/2017

3       $13              01/02/2017

4       $32              05/02/2016

5       $23              05/02/2016

 

I want Output like below:

 

Febuary 2017    Febuary 2016

$24                      $55

1 ACCEPTED SOLUTION
BhaveshPatel
Community Champion
Community Champion

Hi Sac,

 

you should Create a MonthYear Column in your table and drag that onto the visaul along with measure to see the correct results.123.png

 

 

Thanks & Regards,
Bhavesh

Love the Self Service BI.
Please use the 'Mark as answer' link to mark a post that answers your question. If you find a reply helpful, please remember to give Kudos.

View solution in original post

8 REPLIES 8
vanessafvg
Super User
Super User

@Sac

 

i would start with creating a date table

 

https://www.mattmasson.com/2014/02/creating-a-date-dimension-with-a-power-query-script/

 

then create a relationship between your date and the table date

 

then create  measure call total sales

 

total sales = sum(sale)





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Dear,

 

Thank you for solution but it is not working for me. i already tried this one before. Do you have any other that best fit in power bi ?

@Sac what do you mean by its not working for you? be specific with what the problem is





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




I create date and load my data .then make relationship between it.

Then i write this function:

 

totalsales = SUM(Master[Freight Charge]).

 

Its give me only total cost , not month by month . 

 

BhaveshPatel
Community Champion
Community Champion

Hi Sac,

 

you should Create a MonthYear Column in your table and drag that onto the visaul along with measure to see the correct results.123.png

 

 

Thanks & Regards,
Bhavesh

Love the Self Service BI.
Please use the 'Mark as answer' link to mark a post that answers your question. If you find a reply helpful, please remember to give Kudos.

HI Your solution works (apart from "mmmm" which throws error), but the problem of the chronological order in the graph remains. Obviously ordering on the date constructed as you indicate leads to an incongruous result (e.g. 2022-1 / 2022-10 ...). Is there a way to sort chronologically correctly?

example

ordering.jpg

This isn't working for me.  Here's what I get step by step:

 

1- Add month

 

add monthadd month

 

2 - Add november and october from their repsective tables:

 

doesntstack.PNG

 

For some reason every month keeps fanning out to the right rather than just being a row in the same column.  Why does it do this? super annoying...

Thank you. Its work for me

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.