Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Dear Power Bi Users,
I am struggling with a little issue right now. I did some research in this forum but did not find the right solution. Maybe I am just on the wrong path, this is why I hope there might be a simple answer.
This is some sample data. I have a register of various accounts and money which went in and out on these accounts on a certain date. The date is transformed into a month format.
Account | Date | Month | Amount taken | Amount received |
ZZZ Bank | 21.02.2017 | 2017-02 | 10 | |
AAA Bank | 20.02.2017 | 2017-02 | 5 | |
ZZZ Bank | 01.02.2017 | 2017-02 | 7 | |
ZZZ Bank | 01.03.2017 | 2017-03 | 21 |
Now I would like to create a table/formula which can reproduce the information to a total balance each month. So how much money we have in total, thus adding previous month etc.
ZZZ Bank | AAA Bank | Cash | |
2017-01 | |||
2017-02 | -17 | 5 | |
2017-03 | 21 | ||
2017-04 | |||
2017-05 | |||
2017-06 | |||
2017-07 | |||
2017-08 | |||
2017-09 | |||
2017-10 | |||
2017-11 | |||
2017-12 |
With the data I want to create a stacked chart (accounts and their values by month), which should be pretty easy with having the information.
I thought about a CALCUATE Formula, but somehow I do not get it running.
I appreciate any advice or tips.
Thanks in advance.
Sven
Solved! Go to Solution.
Hi @sven7,
You are using a column you should use a measure, columns are always calculated at row level, measures are calculated at context level so taking into account the different levels of information.
Change your column to a measure and it will work,
Regards,
MFelix
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsHi @sven7,
I would add a calendar table to you model but using your columns just add the following measure:
Balance = SUM(Money_In_Out[Amount received])-SUM(Money_In_Out[Amount taken])
then add it to your table.
Regards,
MFelix
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsHi @sven7,
Add a calendar table and don't make any relationship between both tables.
Then add this measure:
Balance = var DimDate = MAX('Calendar'[Date]) return TOTALYTD(SUM(Money_In_Out[Amount received])-SUM(Money_In_Out[Amount taken]),Money_In_Out[Date]<= DimDate)
Regards,
MFelix
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em Português@MFelix Thanks again for your help.
I have tried this approach, but it only gives me the same value for all dates. I have created a seperated table with the calendarauto function, made sure there is no connection to other tables and put in your formula and adjusted it according to my names.
Do you have an idea why there is the same value everywhere?
Thanks in advance and BR
Sven
Hi @sven7,
What is the month column you have in your table is it from calendar or from you data table?
Regards,
MFelix
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsHi @MFelix,
the month column in my table draws the month from the date a booking has been made on an account.
Month = Format(Logs[Date];"yyyy-MM")
This is how my calendar table looks like, there is no connection to the other sheet.
calendar = CALENDARAUTO(12)
BR Sven
hi @sven7,
Create a month column on your calendar table and place that column on your visual
Regards,
Mfelix
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsHi @MFelix,
I used both ways, I am so far that it shows the balance or difference by each month, but not the rolling value. Also it is only showing 2017 and no previous years.
Any further tips are much appreciated thank you so much for your help.
Hi @sven7,
My error mixup two different solutions I was working on.
Create the relationship between both tables and then add this measure:
Balance = TOTALYTD(SUM(Money_In_Out[Amount received])-SUM(Money_In_Out[Amount taken]),'Calendar'[Date])
The other formula without links was to make it month on month no matter the Year so the balence from december would go to January
In that case you need to use the formula:
Balance_1 = var dimdate = MAX('Calendar'[Date]) return CALCULATE(SUM(Money_In_Out[Amount received])-SUM(Money_In_Out[Amount taken]),Money_In_Out[Date] <= dimdate)
and don't connet the tables.
Regards,
MFelix
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsThanks @MFelix, it is getting closer.
I can see the difference for each month now, but still there is no rolling value. When I try to use the month column from the calendar table it gives me an error that it cannot be displayed.
Thanks again.
BR Sven
If you are using the first measure YTD create a relationship between the two tables.
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em Português@MFelix This also works now with the connection to the other table and using the balance formula. However, it gives me the same picture again that it does not show the rolling value. I could only link the date between the tables not the month, following error:
Thanks Sven
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsYes, I tried that but that does not work. It only shows me the difference by month and no rolling value.
I also tried this from
http://www.daxpatterns.com/cumulative-total/
but same graph is shown. Can it be because of my calendar or any other formatting issues maybe?
Cumulative Quantity := CALCULATE ( SUM ( Transactions[Quantity] ), FILTER ( ALL ( 'Date'[Date] ), 'Date'[Date] <= MAX ( 'Date'[Date] ) ) )
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em Português@MFelix Thank you so much for help, I really appreciate your help. Unfortunately still the same issue. I have got the YTD formula, I have set the calendar, I have linked the dates from the logs file and calendar and as the visual I have selected the dates from the calendar.
Hi @sven7,
I have used your data and produced this two models below one with the YTD values and another with the calculated values as you can see both make the same result. so total YTD values sum up to total year, on the second table the rollup goes trough 2018.
Can you send a print with the measures and table to check the values please.
Regards,
MFelix
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em Português@MFelix Thank you for your patience. I do not know where I make my mistake, I have used just some simple data to reproduce your table, but still the same issue. Please see here.
Hope we can find my mistake. BR Sven
Hi @sven7,
You are using a column you should use a measure, columns are always calculated at row level, measures are calculated at context level so taking into account the different levels of information.
Change your column to a measure and it will work,
Regards,
MFelix
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em Português@MFelix What a stupid mistake... All working now, thank you very much.
It really helps to visualize our data. Thanks
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
114 | |
99 | |
83 | |
70 | |
60 |
User | Count |
---|---|
150 | |
115 | |
104 | |
89 | |
65 |