PowerBI AND/OR function between 3 tables - powerbi

I have the following table created in a Dashboard:
Name Exist in AD Exist in EDR Exist in ASDF
A TRUE TRUE TRUE
B TRUE TRUE TRUE
C FALSE FALSE TRUE
Every field cames from a different tables. I would like to calculate in a dashboard a new column with the following result:
New Column = AND (Exist in AD,(OR(Exist in EDR,Exist in ASDF))

You can use the following DAX:
New Column =
var nameVar = table[Name]
var existAD = CONTAINS(AD, AD[columnNameAD], nameVar)
var existEDR = CONTAINS(EDR, EDR[columnNameEDR], nameVar)
var existASDF = CONTAINS(ASDF, ASDF[columnNameASDF], nameVar)
return existAD && (existsEDR || existsASDF)
Caintais returns true if Name of the variable in the Row exists in other table in that column.
At the end I put it logic together..

Related

MdxScript(Model) cslculation error in measure : A table of multiple values was supplied where single value was expected

İ want to find sufficient stock according to sale.
Measure =
VAR _date = VALUES(dateofdata)
VAR opening_date = VALUES('Stores' [Opening date])
VAR dayfornewstores = _date-opening_date
VAR _days = 28
VAR avg_sales = IF(opening_date<28,[TotalSales]/opening_date,[TotalSales]/_days)
VAR qual_days = [TotalStocks]/avg_sales
RETURN qual_days
When I use this measure in table for each store it is success. But when I want all of my stores number of days to qualify for sale in card visual there is error. How can I solve it?

DAX Power BI - addcolumns to calculated table

I have a task to compare 2 dynamic periods from the table (MOO).
Th idea is to get clients which are in both dates and compare them by 1 field (Rating_rank).
But my created field calculates max from all table, not grouping by client.
What should id do?
rate_worse_tab =
var min_dt = calculate(min('MOO'[value_day]),ALLSELECTED('MOO'[value_day]))
var max_dt = calculate(max('MOO'[value_day]),ALLSELECTED('moo'[value_day]))
var cur_cl = CALCULATETABLE(values(MOO[CLIENT_UK]),filter(MOO,MOO[VALUE_DAY]=max_dt))
var old_cl = CALCULATETABLE(values(MOO[CLIENT_UK]),filter(MOO,MOO[VALUE_DAY]=min_dt))
var combo_table = CALCULATETABLE(values(MOO[CLIENT_UK]),filter(MOO, MOO[CLIENT_UK] in cur_cl && MOO[CLIENT_UK] in old_cl))
var f_table = ADDCOLUMNS(combo_table,"Old_rate_rank",calculate(max(MOO[Rating_rank]),filter(MOO,MOO[VALUE_DAY]=min_dt && MOO[CLIENT_UK] in combo_table)))
return
f_table

How to create a new column based on previous row with DAX - PowerBI

Hi on powerBI I have something like this
Desire result is this to create another column 'is_repeat from previous row'
where it is 'True' when the current row is repeat the top row
I tried to use 'EARLIER' function to compare current row to previous but EARLIER grey out my 'index' column - not sure why
thanks in advance!
Calculated Column:
=
VAR ThisIndex = Table1[INDEX]
VAR PreviousIndex = ThisIndex - 1
VAR ThisCode = Table1[code]
VAR PreviousCode =
LOOKUPVALUE( Table1[code], Table1[INDEX], PreviousIndex )
RETURN
ThisCode = PreviousCode

How to subtract the value of another row depends on Category column in PowerBI

Here is the photo explanation
I want to show the NewLinePrice in "Other Service", the value will subtract the value of "Graphic Design", so the first column will show ‭1152245‬ and so on.
So far i've tried to defined the new column "NewLinePrice", the following is the formula but not work
NewLinePrice =
Var category = 'Group-dtl'[ProductCategoryName]
var graphic_line_price = CALCULATE(SUM('Group-dtl'[LinePrice]),FILTER('Group-dtl', 'Group-dtl'[ProductCategoryName] = "Graphic Design"))
var graphic_line_price_temp = IF(category = "Graphic Design", 'Group-dtl'[LinePrice], 0)
//var graphic_line_price = 1
Var pre_result = IF(category = "Other Service", 'Group-dtl'[LinePrice] - graphic_line_price, BLANK())
Var result = IF(pre_result > 0, pre_result, BLANK())
return result
Anyone have ideas how to do that?
I spend some time to find the answer for your question, at the end I discover that to achiever your outcome, you cannot perform the calculation within the original but to create a new table, the reason is unknown, however at least it is achievable, see my answer below and accept if help, appreciate my hardworking :)
This is my original table name [Sheet1]
First I create a new table based on the original table
Table =
ADDCOLUMNS(VALUES(Sheet1[Product Name]),
"Sales",CALCULATE(SUM(Sheet1[Amount]),
FILTER(ALL(Sheet1),Sheet1[Product Name]=EARLIER(Sheet1[Product Name]))))
From the new table, I add new column using the following formula to return different value only for "Other Service"
New Line1 =
Var ServiceValue = CALCULATE(MAX(Sheet1[Amount]),Sheet1[Product Name] = "Other Service")
Var graphicValue = CALCULATE(MAX(Sheet1[Amount]),Sheet1[Product Name] = "Graphic Design")
Var charge = ServiceValue - graphicValue
return
if('Table'[Product Name] = "Other Service", charge,'Table'[Sales])
Here is new table with updated value:

Apex Interactive Grid how to retrieve a specific record

I am retrieving my grid data using:
var ig$ = apex.region("myGrid1").widget(),
view = ig$.interactiveGrid("getCurrentView");
Now I want to check for a specific record based on 2 columns: id1 and id2 where id1 = 1 and id2 = 7
How can I do that with javascript?
You can iterate for each record like this:
//"myGrid1" should be the static id of the IG region
var widget = apex.region('myGrid1').widget();
var grid = widget.interactiveGrid('getViews','grid');
var model = grid.model;
var results = [];
model.forEach(function(r) {
var record = r;
//the name of the columns should be ID1 and ID2, if not
//make the necessary changes using "_" to represent "space"
var value1 = model.getValue(record,'ID1');
var value2 = model.getValue(record,'ID2');
if(value1 == 1 && value2 == 7) {
results.push(record);
}
})
console.log(results);
To test this code, execute it on console.
To start the console on chrome just press F12
good luck.