Im a new user in Power BI and im having a lot of trouble trying to convert my formulas in excel to work in Power BI.
My main issue is figuring out how to convert IF(AND(OR and several IF's. I have several formulas similar to this one so with the help of converting this one I could most likely do the rest based off this one.
Parameters would be a table in power bi.
E2, Q2, $B$2, etc. would be columns/fields in different tables in power bi.
=IF(E2="";"";IF(AND(OR(E2="Critical";E2="Maximum";E2="Urgent");Q2*24>Parameters!$B$2);"NO";
IF(AND(OR(E2="Alta";E2="High");Q2*24>Parameters!$B$3);"NO";
IF(AND(OR(E2="Media";E2="Medium");Q2*24>Parameters!$B$4);"NO";
IF(AND(OR(E2="Baja";E2="Low");Q2*24>Parameters!$B$5);"NO";
"YES")))))
This formula would be in a new column inside one of the tables.
You already did the work, it's very very similar, I've just added a new column and modify your formula like this:
Column = IF(Table1[E2]="","",
IF(AND(OR(Table1[E2]="Critical",OR(Table1[E2]="Maximum",Table1[E2]="Urgent")),Table1[Q2]*24>Table1[B2]),"No",
IF(AND(OR(Table1[E2]="Alta",Table1[E2]="High"),Table1[Q2]*24>Table1[B2]),"No",
IF(AND(OR(Table1[E2]="Media",Table1[E2]="Medium"),Table1[Q2]*24>Table1[B2]),"No",
IF(AND(OR(Table1[E2]="Baja",Table1[E2]="Low"),Table1[Q2]*24>Table1[B2]),"No","YES"
)
)
)
)
)
Where Table1 is my table, E2,Q2 and B2 are my columns name. About the "Q2*24", because you look like to use always Q2 and not Q2,Q3,Q4,... you can use one VAR instead of a full column with always the same value, like this:
Column =
VAR ReplaceQ2 = 10
RETURN
IF(Table1[E2]="","",
IF(AND(OR(Table1[E2]="Critical",OR(Table1[E2]="Maximum",Table1[E2]="Urgent")),ReplaceQ2*24>Table1[B2]),"No",
IF(AND(OR(Table1[E2]="Alta",Table1[E2]="High"),ReplaceQ2*24>Table1[B2]),"No",
IF(AND(OR(Table1[E2]="Media",Table1[E2]="Medium"),ReplaceQ2*24>Table1[B2]),"No",
IF(AND(OR(Table1[E2]="Baja",Table1[E2]="Low"),ReplaceQ2*24>Table1[B2]),"No","YES"
)
)
)
)
)
Hope this help
=IF(AND(LEFT(L6,3)="CGK",LEFT(M6,3)="CGK"),"Intracity",IF(AND(LEFT(N6,3)="CTC",LEFT(L6,3)=LEFT(M6,3)),"Intracity",IF(AND(LEFT(L6,3)=LEFT(M6,3),LEFT(N6,3)<>"CTC"),"Intercity","Domestik")))
Related
I am facing the issue of reusing neat Excel formula for MAXIFs in Power Query M language.
The formula itself consists of several conditions regarding columns in Table2 and a value of interest (VOI) in Table1 (both being Excel table objects).
formula in Table1:
=MAXIFS(Table2[columnA],Table2[columnB],"criteriaB1",Table2[columnC],[#[VOI]],Table2[columnA],"<="&MINIFS(Table2[columnA],Table2[columnB],"criteriaB2",Table2[columnC],[#[VOI]])
(I will divide the formulas into lines to make reading easier)
=MAXIFS(Table2[columnA],
Table2[columnB],"criteriaB1",
Table2[columnC],[#[VOI]],
Table2[columnA],"<="&MINIFS(Table2[columnA],
Table2[columnB],"criteriaB2",
Table2[columnC],[#[VOI]])
So far I've been trying merging Table1 with Table2, grouping by some of the columns but as result I receive chunks of data that I can't/don't know how utilize in next steps. I simply cannot see the complete landscape of the procedure in Power Query M language.
Any help would be appreciated.
The corresponding idea would be to take a maximum over a filtered table.
For example, the MINIFS part would look roughly like this:
MinA =
List.Min(
Table.SelectRows(
Table2, each [ColumnB] = "criteriaB2" and [ColumnC] = "VOI"
)[ColumnA]
)
It gets a bit trickier since you need to pass the current row value of Table1[VOI] into the second condition but it's still doable and might look something like this:
AddMinAColumnToTable1 =
Table.AddColumn(
Table1, "MinA",
(Tab1Row) =>
List.Min(
Table.SelectRows(
Table2, each [ColumnB] = "criteriaB2" and [ColumnC] = Tab1Row[VOI]
)[ColumnA]
)
)
I recommend reading this blog post for a better understanding of the each and (_) => constructions.
Hello i want to sum a column but i need to filter the table based on data from another table.
So i have table1 where i want to sum points and i want to sum only the record that for the dates and the names and the classes i find in table 2
I am using measure like this:
Measure 3 = CALCULATE(sum(Table1[points]);Table1[name] in (ALLSELECTED(Table2[name]));Table1[date] in (ALLSELECTED(Table2[date]));Table1[class] in (ALLSELECTED(Table2[class])))
but it does not filter properly,
is there any better way to do this?
One way would be, you create a relationship between the two tables. I think Power BI doesnt support multi relationships between two tables, so you have to add a custom column on both tables with your key <> foreign key. In your case like you mentioned it woulb be the name, date and class (in the query editor):
Key = [name] & [date] & [class]
In my sample here I just use the name as key column.
If the relationship is set you can use the following measure:
You can use TREATAS to filter Table1 based on Table2. No relationship is needed.
Total Points Filtered By Table2 =
CALCULATE (
SUM ( Table1[point] ),
TREATAS (
SUMMARIZE ( Table2, Table2[name], Table2[date], Table2[class] ),
Table1[name], Table1[date], Table1[class]
)
)
I'm trying to figure out DAX language for Excel and Power BI.
Currently I'm facing a problem when trying to make measurements. I have 2 columns, Resign and Active.
I want to count the rows where the combination is: Resign=1 and active=0.
Do you know how to make this measurement?
Thanks!
Is difficult help you without any data, but if you have the Table 1 for example and the columns that you describe, can do it:
Combination = CALCULATE(COUNTROWS('Table 1'),FILTER('Table 1',AND('Table 1'[Resign]=1, 'Table 1'[Active]=0)))
Please tell me if this help you!
In this case the FILTER-function is not necessary. (referring to the accepted answer). Just using CALCULATE is more efficient. Like so:
Combination =
CALCULATE ( COUNTROWS ( 'Table 1' ); 'Table 1'[Resign] = 1; 'Table 1'[Active] = 0)
I have a problem which can be solved in either excel or power bi. From the image provided i want to create a new column so that the Program/Course will only contain the values Program and values containing Kurs will be in their own column. Is there a way to do that using either excel or Power BI.
I would use the Query Editor to rename the current Program/Course column, then create 2 Conditional Columns to split the data the way you want e.g.
Program/Course = if [Program/Course - Original] <> "Kurs" then [Program/Course - Original] else null
Course = if [Program/Course - Original] = "Kurs" then [Program/Course - Original] else null
Finally I would remove the renamed column.
i'm new to dax. im trying to sum the amount of fatalities per year.
My formula:
= SUMMARIZE (
'TableCrash',
'TableCrash'[Year],
"Fatal", SUM ( 'TableCrash'[Fatalities] )
)
-
example:
SUMMARIZE(<table>, <groupBy_columnName>[, <groupBy_columnName>]…[, <name>, <expression>]…)
Source
There isn't anything wrong with your formula. The problem is how you are using it. Because it returns a table you would usually incorporate this snippet into a larger formula. You can install DAX Studio into Excel to test these snippets. In this case you would execute:
EVALUATE
(
SUMMARIZE (
'TableCrash',
'TableCrash'[Year],
"Fatal", SUM ( 'TableCrash'[Fatalities] )
)
)
But if you have a table that contains Year and Fatalities you don't need any formula to calculate sum of Fatalities. Try to drop both fields into a Power View or pivot table and Fatalities will sum automagically.