Running total vertically - Power BI - powerbi

I have a dataset:
If I were to create a payment inflow matrix per a cohort where payment created_date is in columns and created date formatted as a cohort is in rows, it will look like:
I need to calculate running total per a column - see below:
There could be other fields in the table, e.g. product type which should influence running total.
I've seen the standard solution with = calculate(sum([X]), all(table), [date]<=max[date]) but I cannot make it work. What am I doing wrong? .pbix is uploaded at https://drive.google.com/file/d/1E3qJyOv11xSOlVRHAL9uq2C1Zho-g3zc/view?usp=sharing

You can use one of Power BI's build-in Quick measures:
This will give you the following result:
However, you won't get any aggregation for Jan and Feb since there are no according records in 2022-2. It looks like created_q is actually order_q?
When this is important, you would have to add dummy zero amounts with 2022-2 order_date.

Related

Power BI - How do I use calculated values from various tables and store them in a separate table

I'm trying to figure out a solution to my problem. Basically we get a monthly report with about 3000 records and there's a bunch of reporting that is done on that, and there are calculations based on various columns. e.g.
Date
Total usage
Recommended reduction
Product
01.01.2022
1000
500
A
01.01.2022
1300
70
B
01.01.2022
2000
900
C
...
...
...
At the end of it Power BI kindly sums up the columns which is great, but now what I am trying to do is take the sum of these columns and store them in a summary table so that it would be something like this so that I could use it for a time series visual
Month
Sum Total Usage
Sum Recommended Reduction
January
59720
12040
February
81020
20580
...
...
...
I have no idea how to go about doing this. Is this the right way to go ? Or is there a way to create a visual without having to create a summary table ? I'm at a bit of a loss, so any suggestions would be really appreciated.
You don't need any DAX calculations for that. Simply pull your data onto the fields of a line chart visual like shown below. Note that you have to drill-down from Year to Month to actually see the lines.

Add missing month rows based on multiple columns with multiple variables in Power BI

I'm very stuck and I was hoping you can help. So have the following dataset (Table 1) with Month (5 years worth), Customer (1000 customers), Product (100 products), Units and Value (value is just unit multiple a price). The data only shows rows with unit and value, so for customers when there is no sale in a month, there is no data.
Click here for Table 1
I want to create a table (Table 2) where every product for every customer is shown for all time periods, where actual units and values are included and those missing in Table 1 are now showing 0.
Click here for Table 2
I have read many posts here and elsewhere, which only handles 1 column (e.g. only Customer not both Customer AND Product, and only 1 measure not Unit and Value). I tried to adapt the code but failed miserably.
I also want to do this in Power BI using M not DAX, because I would like to further transform the data.
Thank you so much everyone!!!
Good afternoon.
You can use DAX to create a calendar for the required period of time.
Use the minimum and maximum values from Table 1 for the interval (Calendar function).
Calendar = CALENDAR(Date(2022,5,1), TODAY() -1)
Link the calendar to the necessary dates.
calendar link example
In the settings of the table to which you will output data, select the "Show items without data" setting, and take the date from the calendar.

DirectQuery - Very inefficient queries being generated to Snowflake

I am connecting PBI to Snowflake using DirectQuery. To keep it simple, I have two tables, a product dimension table and a sales fact table. There are 3.7M rows in the product dimension table and 100M in the sales fact table. I also have a measure that calculates total sales which uses SUM to sum a column in the fact table.
I create a table visual in PBI and put the product description as the first column. The query generated by PBI is good. It retrieves 501 rows and displays them. So far, so good. Next I put the total sales measure as the second column. Now PBI generates several queries retrieving 1,000,001 rows. Of course I get an error stating the 1M row limit for DirectQuery has been reached.
This should not be happening. Has anyone run into something like this? Is there anything I can do?
I had a dig around and there is a capability to adjust the limit if you have a premium license
https://powerbi.microsoft.com/en-gb/blog/five-new-power-bi-premium-capacity-settings-is-available-on-the-portal-preloaded-with-default-values-admin-can-review-and-override-the-defaults-with-their-preference-to-better-fence-their-capacity/

How to deal with missing dates in Power BI line charts? (Tabular SSAS)

In SSAS Tabular mode, we have different tables with slowly changing dimensions (SCD Type 2). In Power BI, we now want to show for example the price history for one object over time. I want to display that with a Line Chart.
For the sample data, I added a Line Chart and activated the "Stepped" property in "Shapes", to have a clear cut of the price change. But unfortunately, Power BI displays the price change on Oct 5th (because this is the middle date between 3th and 7th) instead of Oct 7th. I know, that I would be able to solve it on database view layer, but I don't want to create so much data records for all different tables.
PRICE TABLE
**************************************
Price Valid from Valid To
**************************************
3'674 02.10.2019 02.10.2019
3'674 03.10.2019 06.10.2019
11'095 07.10.2019 07.10.2019
11'095 08.10.2019 01.01.2999
**************************************
Is there any way to prevent this behavior in the Power BI visualization or can I somehow calculate the missing dates in DAX?
I would have use date field from date dimension which has all the continuous date, then you may change your axis type for date continuous and it will generate smooth transition.

Sumif using page, report and visual level filters

I have two tables that are related by an ID column called 'Program_Code' (1:Many).
'Program_Summary':
Program Code = each row has a unique ID, e.g. HI-18, HI-17
Program Name = name of a program, e.g. Home Improvement
Incentive Spending = calculate(sum(Program_Data[Incentives]))
'Program_Data':
Program Code = many rows with the same ID
Incentives = incentive amount to summarize in Program Summary table
Record Status = Claimed, Pipeline or Rejected
Record Fiscal Year = 2017, 2018 or 2019
I created a Power BI table that has rows organized by 'Program Name'. Note that each program name like "Home Improvement" may have more than one code associated with it, e.g. HI-18 and HI-17 corresponding to fiscal years.
I'm hoping to summarize Incentive Spending by program name, and use page/report level filters to restrict results. The Report Level filters are:
Record Fiscal Year = 2017
Record Status = Claimed
But, the calculate(sum(Program_Data[Incentives])) filter ignores these page level filters. How do I fix this?
You created "Incentive Spending" as a calculated column. Instead, you need to create it as a measure.
Calculated columns are calculated only once - when you create them, or when you reload data. After that, calculated columns contain only static data, and can not respond to any filters.
Measures, on the other hand, are dynamic formulas that recalculate any time you change any filters.
To fix your problem, simply create a new measure from "Modeling" tab:
and add DAX code:
Incentive Spending = SUM(Program_Data[Incentives])
(no need to use CALCULATE here).
Drop this measure into a table or matrix, and it should work. Instead of page/report level filters, I'd recommend to use slicers - create a slicer for Fiscal Year, and another slicer for Record Status. They will allow you to filter the calculation with ease.
You can use:
CALCULATE(sum(Program_Data[Incentives]);Program_Data[Record Fiscal Year] = 2017 && Program_Data[Record Status] = "Claimed")
However, I do not understand why you would need this because you have 2 tables with the right link, this should give you all possibilities with the table/matrix visualization what you need to show correct results..