Power BI - New rows with inhereted values - powerbi

got table
Period
Entity
Value
NOV 2020
Entity 1
20
DEC 2020
Entity 1
30
JAN 2021
Entity 1
25
Now I want to insert row for every period with same value but different entity, so my table looks like this:
Period
Entity
Value
NOV 2020
Entity 1
20
NOV 2020
Entity 2
20
DEC 2020
Entity 1
30
DEC 2020
Entity 2
30
JAN 2021
Entity 1
25
JAN 2021
Entity 2
25
Is it something I have to do in query editor through new custom column? Or just through new measure after data load?
Basically what I really need is to present in visual "Entity 2" with same values as "Entity 1" for multiple preiods.
Any ideas?
Thank you

Follow these below steps in Power Query Editor-
Step-1: Duplicate your base table.
Step-2: Replace value "Entity 1" with "Entity 2" in the Entity column of your new table.
Step-3: Now select Append Query as Ne option from the ribbon and select both old and new table.
Finally you will find the below output in your newly created/appended table-

Related

How to create a monthly summary table in Power BI

In PowerBI, I have a table with data in days
Table 1
Day
Order
1/1/2022
3
1/31/2022
5
2/2/2022
7
2/11/2022
12
3/1/2022
31
4/31/2022
5
4/2/2022
7
6/11/2022
21
And I want to have a summary table for months like
Table 1
Month
Order
1 2022
8
2 2022
19
3 2022
31
4 2022
12
6/11/2022
21
How can I do that using DAX?
Sure. Create a Calculated Table using the SUMMARIZECOLUMNS function.
Something like:
OrdersByMonth = summarizecolumns(MyTable[Month], "Orders", sum(MyTable[Orders]))

Filter only MAX month figures Power BI Desktop

I have a table of values for orders per month by region that looks like this:
Orders Table
Orders (YTD)
Month
Year
1
Jan
2021
4
Feb
2021
4
Mar
2021
5
Apr
2021
14
May
2021
16
Jun
2021
17
Jul
2021
19
Aug
2021
22
Sep
2021
24
Oct
2021
34
Nov
2021
35
Dec
2021
1
Jan
2022
3
Feb
2022
4
Mar
2022
Along with a table that orders the months in sequence as below, that will be modelled to order the months in the first table so that they appear in sequence in graphs.
Monthly Sequence Table
Month Sequence
Month
1
Jan
2
Feb
3
Mar
4
Apr
5
May
6
Jun
7
Jul
8
Aug
9
Sep
10
Oct
11
Nov
12
Dec
Upon closer inspection of my data, I have realised that the number of orders per month are not the raw figure per month, but a cumulative total for every order in the calendar year so far (new orders for month + orders for preceding month). Firstly, I want to calculate the correct sum of orders per year, which should actually just be the MAX month from the orders table. Of course in most years this will be December, but for the current year it needs to be the latest month. I wanted to use a measure to calculate the MAX 'Monthly Sequence Table'[Month Sequence] number from each table, by year. I thought maybe a filter function would be used but could not work out exactly how to do this in DAX.
Secondly, and similarly, I want to calculate the actual number of orders per each individual month using DAX. In this case, I want to take the Orders (YTD) total for that month/year combination and subtract it from its immediately preceding month. What would the formula look like for this?
Thanks in advance.

How to count number of projects that got approved or the status changed in DAX

I have a data set that looks like below. The data is about project ideas that are raised in our company. The project ideas will be kept in Backlog section first and then moved to Do Next once then get approved. The modified date is a date when the project idea reviewed and approved or the status changed to Do Next. If it is not approved, then it remains in Backlog.
Id Modified Date Created Date Status
1 8/4/2017 8/4/2017 Backlog
2 6/10/2021 6/10/2021 Backlog
3 3/5/2018 3/5/2018 Backlog
1 6/5/2020 8/4/2017 Do Next
1 30/5/2021 3/5/2020 Analyze
2 5/4/2022 6/10/2021 Do Next
2 8/8/2022 6/10/2021 Analyze
What I want to achieve is that, I want to count how many projects moved from Backlog to Do Next status using DAX function or approved. So this time, for example I have two projects that moved from Backlog to Do Next (Id1 and Id 2). I am relatively new to DAX. Can anyone please help me on this?
I have modified your table to add an "orphan" Do Next Status, as the last row, to test the count dependency on the previous Status Backlog.
Assuming your table look like this
Table
Id
Modified Date
Created Date
Status
1
08 April 2017
08 April 2017
Backlog
2
06 October 2021
06 October 2021
Backlog
3
03 May 2018
03 May 2018
Backlog
1
06 May 2020
08 April 2017
Do Next
1
30 May 2021
03 May 2020
Analyze
2
05 April 2022
06 October 2021
Do Next
2
08 August 2022
06 October 2021
Analyze
4
09 August 2022
06 October 2021
Do Next
Calculation
Count Projects =
VAR BacklogProjects =
SUMMARIZE ( FILTER ( 'Table', [Status] = "Backlog" ), [Id] )
VAR DoNextProjects =
SUMMARIZE ( FILTER ( 'Table', [Status] = "Do Next" ), [Id] )
VAR SameProjects =
INTERSECT ( BacklogProjects, DoNextProjects )
VAR Result =
COUNTROWS ( SameProjects )
RETURN
Result
``

Can PowerQuery append rows based on columns?

Hello StackOverflow Community,
I have a Dataset where the monthly volume's values per Model is shown in multiple columns instead of one. I.E:
Model Jan Feb Mar Apr May
A 5 12 26 56 23
Is it possible through PowerBI's PowerQuery to create one "Month" column where its values are being appended? Example:
Model Month Volume
A Jan 5
A Feb 12
A Mar 26
A Apr 56
A May 23
Thanks in advance.
You need to use 'Unpivot columns', in the transform options of the query editor
Select the columns you want, then Unpivot.
You should give you this:
It will name the new columns Attribute and Value, you can then rename them to what you want. FYI when the next month (Jun) is added to the source it should unpivot that column automatically.

Calculate Variance in PowerBI using dax query

I am trying to create a variance measure in PowerBI.
This is the data that I have,
Month Year MonthNo Value
Jan 2016 1 700
Feb 2016 2 800
March 2016 3 900
April 2016 4 750
.
.
Jan 2017 13 690
Feb 2017 14 730
And My variance for the Month Number 7 should be like,
`{Avg(values(4,5,6) - Value(7)} / Value(7)`
i.e (Average of last 3 months value - current month value) / Current month value
How to do this in Power BI? Thanks.
If it is okay for you to use a column, I believe you could add one with this code to get what you want:
Variance = (CALCULATE(AVERAGEX(Sheet1,Sheet1[Value]),FILTER(FILTER(Sheet1,Sheet1[MonthNo]<=EARLIER(Sheet1[MonthNo])-1),Sheet1[MonthNo]>=EARLIER(Sheet1[MonthNo])-3))-Sheet1[Value])/Sheet1[Value]
You'll need to replace all instances of Sheet1 with the name of your table.
It'll give you something like this: