I am new to PowerBI and I am facing a challenge with creating a calculated column that will get updated automatically as the dataset keeps getting filtered. My dataset looks like this -
I have created the Deliverable_Milestone_Match column using the formula -
Deliverable_Milestone_Match =
IF(
Sheet1[Issue_Type] = "CO Deliverable",
VAR _sel = SELECTCOLUMNS(
Sheet1,
"MilestoneIssueKey",
[Issue_Key]
)
RETURN
IF(
Sheet1[MilestoneIssueKey] IN _sel,
"MAPPED",
"UNMAPPED"
),
"MILESTONE"
)
Now, the challenge is, that I will need to apply some filters to this dataset, and since my calculated column references other columns in the data, it also needs to change accordingly. For example The formula is looking up the presence of MilestoneIssueKey in Issue_Key, and it is populating MAPPED if it gets a match, and UNMAPPED otherwise. Now, if I apply a filter that removes a specific unique Issue_Key, then the corresponding MilestoneIssueKey won't have a match anymore, and the Deliverable_Milestone_Match value should change to UNMAPPED now.
I would appreciate it if anyone can help me with this. I am not even sure if this can be achieved via DAX or whether I will need to use Power Query for this.
Thanks in advance!
You first issue is the following:
[...] calculated column that will get updated automatically as the dataset keeps getting filtered
Calculated columns aren't refreshed dynamicaly as filter context evolves. As explained here :
Since calculated columns live at the same level as your tables, they are only calculated when you first define them and during a dataset refresh.
So, in that regard you should try to solve your problem using Measures.
Related
Is it possible to add a card in power BI that shows the last time the underneath dataset has been updated?
Many thanks!
You can create a blank query and use the following M query to create a single-cell table:
let
Source = #table(type table[Last Refresh=datetime], {{DateTime.LocalNow()}})
in
Source
And then you can use the Card visual and drag in the column to show it. You can rename the field to remove the default aggregation. (It doesn't matter since there is only one row of data anyways)
The value will be recalculated each time the data is refreshed.
you can achieve this by adding a calculated column (Refresh data Column) in the model with the formula =NOW()
Then add measure
Last Refresh Date :=MAX(Table[Last Refresh Column])
Since calculated columns are calculated only on model refresh - it will make sure the calculation is right.
The below code is working for me (for HK).
Add a column with the below formula
Last Refresh = FORMAT(UTCNOW()+TIME(8,0,0),"dd MMMM YYYY ttttt")
Depending on the location it's really confusing with all those functions..
Let me suggest you the workable one:
Go to the:
Query Editor
1.right click on the Queries body on the left side
2.new queries
3.Blank Queries
4.Paste the following formula by putting the right Server Instances and DB Name,
" = Sql.Database("Server\Instance", "Database", [Query="select GETDATE() LastRefreshDate from AnyTableName"])
It'll work out. And since it's pulling directly from the server,, you don't have to worry about choosing the right DateTimeZone functions in PowerBI.
I have a PowerPivot table that has a column of IDs and a linked table that contains a set of specific IDs that I want to use to create an indicator variable which I can use to sort on in existing tables and charts. Essentially I want:
If the value in column EpisodeID is found anywhere in LostEpisodes[LostID], then return the value "1", otherwise "0".
LostEpisodes is the linked table and LostID is the column that contains the subset of IDs I want to be able to sort on.
I have tried using =IF(VALUES(LostEpisodes[LostID])=[EpisodeID],1,0) but got an error. Is my syntax wrong or should I be using a different approach? Seems simple enough, but I am new to PowerPivot and DAX.
Thanks
OK - So I have found an answer that works and wanted to share. Others may have more elegant solutions, but this worked. This is where I miss MATCH.
I have a linked table called LostEpisodes which contains 2 columns, EpisodeID and Lost (all contain the value of 1 as they are all lost episodes). For my purposes I am manually entering the episode IDs as there are only a few. EpisodeID is also in the main table and is the column I am matching on.
I started with one new column labeled LostLookup with the following formula:
=LOOKUPVALUE(LostEpisodes[Lost],LostEpisodes[EpisodeID],[EpisodeID])
I then created a new column with the following formula:
=if(ISBLANK([LostLookup]),"NotLost","Lost")
This creates the indicator variable I can now use in pivot tables and charts. I have tested it and it works great.
Hope this makes sense!
I have a report that in the values I have 2 data sets, and then grouping by a location to display the data. If I use the one location within 1 dataset then sure one of the averages I am displaying is perfect but the other is incorrect showing the same result across the board.
No down I need to join these together to get an outcome.
here is what I have:
Values:
1. =Avg(Fields!Rating.Value)
2. =((sum(Fields!Low_rating.Value,"MIN_MAX_CCR") + sum(Fields!Max_rating.Value, "MIN_MAX_CCR")) / 2 ) / Count(Fields!Case_ID.Value, "MIN_MAX_CCR")
Category Grouping:
1.=lookup(Fields!CaseID.Value,Fields!Case_ID.Value, Fields!location.Value,"MIN_MAX_CCR")
So the first field is from the current dataset, the second is from the MIN_MAX_CCR dataset, the location is from the first data set, and then getting the data set for the case_ID.
Now when I run this I get this lovely error:
System.Web.Services.Protocols.SoapException: The Group expression for the grouping ‘Chart8_CategoryGroup’ refers to the field ‘location’. Report item expressions can only refer to fields within the current dataset scope or, if inside an aggregate, the specified dataset scope. Letters in the names of fields must use the correct case.
at
I just cant see a way around this - I cant combine the data in one query due to the nature of the query differences.
You are trying to return location from MIN_MAX_CCR, but it doesnt exist.
I would read the documentation or intellisense hints on the Lookup function to learn how to write it correctly.
In my PowerPivot I have a master data table which comes via an extract from system x. Now I want to be able to "GROUP BY" over a certain column from the same data. What would be the best approach here? There are more than 600.000 lines involved.
I have already tried following DAX query but it won't work:
SUMMARIZE('SAP extract', [cost element], sum('SAP extract'[val]))
Returns:
Query(1,, 47) Function SUMMARIZE expects a column name as argument number 3.
Kris,
I would suggest creating a new measure -- guessing from you question, that would probably be a simple SUM (see documentation here), something like:
=SUM(Sales[Amt])
This should be then automatically added to your currently active powerpivot table.
If you then want to group the data by anything, simply drag the dimension into the rows section and you should be able to see the aggregated sums sliced by the dimension you chose.
Hope this helps.
I want to do a calculation using two different datasets, but I cant seem to do it in the expression field. Any ideas on how I can add, multiply or divide using the two datasets? In the Fields, I added a new one and trying to set the expression only gives me DataSet1, but I want to add a DataSet2 field and a DataSet1 field.
Thanks guys
You can not directly use two data sets in there.
Imho you should move your data to db queries, then add a query that does your job, include this in your report then.
Alternative you can calculate some aggregat in a field, hide the field, do this with more/many as you want, then use your operatores on the result fields.