name of skill function get list of master children layout cells used in current design - cadence

Does Cadence Virtuoso have a skill function to get list of master children layout cells used in current design?
I've tried to work with
ddGetObjChildren
but this function returns children of datatypes for my top cell: schematic, abstract , etc.
I need list of layout children masters used in this top cell.

I got solution from Cadence Support Team!
procedure( TrHierTraversal( cellView cellList )
foreach( master cellView~>instances~>master
let( ( nextCellView )
nextCellView = master
cond(
( !nextCellView nil )
( member( nextCellView cellList ) nil )
( t
cellList = TrHierTraversal( nextCellView cons( nextCellView cellList ) )
) ; t
) ; cond
) ; let
) ; foreach
cellList ;;; return value - list of all master cells in hierarchy
) ; procedure
expansion = TrHierTraversal( dbOpenCellViewByType( "MAIN_LIB" "mux" "layout" ) nil )
foreach( item expansion printf("%L" item~>cellName))

Related

Harvesting multiple Slicers [Power BI]

For a scorecard, I need to weigh some categories based on importance. Said weights must be selectable from a filter based on their category (categories might have different weights).
I created a table with the weights with the percentages to multiply against and created the below:
CAT3 Selection
cat3 Selection =
IF (
SUM ( Query1[CAT3 Error] ) = BLANK (),
BLANK (),
IF (
HASONEVALUE ( 'Weighted Percents'[CAT3 Weight] ),
VALUES ( 'Weighted Percents'[CAT3 Weight] ),
0
)
)
CAT4 Selection
cat4 Selection =
IF (
SUM ( Query1[CAT4 Error] ) = BLANK (),
BLANK (),
IF (
HASONEVALUE ( 'Weighted Percents'[CAT4 Weight] ),
VALUES ( 'Weighted Percents'[CAT4 Weight] ),
0
)
)
cat3 Weighted Scenario
( [cat3 Selection] * 1 ) * SUM ( Query1[cat3 Error] )
cat4 Weighted Scenario
( [cat4 Selection] * 1 ) * SUM ( Query1[cat4 Error] )
My problem is this: When I select a slicer, it works, but it also automatically selects the same value on the other slicer. If I edit the interactions between the two slicers, I get a value of 0 in the data unless they are the same. How can I fix this?
This is a rather convoluted way of harvesting slicers. A more standard way to write things would be like
cat3 weighted =
SELECTEDVALUE ( 'Weighted Percents'[CAT3 Weight] ) * SUM ( Query1[cat3 Error] )
cat4 weighted =
SELECTEDVALUE ( 'Weighted Percents'[CAT4 Weight] ) * SUM ( Query1[cat4 Error] )
If this simplified construction still has the same problem, then I would recommend using independent tables for your slicer selections rather than having just the one.
Just needed to remove the relationship of the duplicated weight tables and use multiple tables

DAX subquery measure?

I'm struggling with a DAX query and wondered if you could help?
Consider this table (or visualisation) called 'Builds':
Build....App....Status
Build1...App1...UAT
Build1...App2...Complete
Build2...App1...Complete
Build2...App2...Complete
I would like to add a measure column called 'AppsOutstanding' to show a count of Apps for that Build that aren't 'Complete'. Like so:
Build....App....Status......AppsOutstanding
Build1...App1...UAT.........1
Build1...App2...Complete....1
Build2...App1...Complete....0
Build2...App2...Complete....0
I almost need to do a 'subquery' measure!? Something like:
SELECT COUNT(Status) FROM Builds
WHERE Build = [The Build In This Row]
AND Status <> 'Complete'
I'm a bit stumped how to translate this into DAX? Here is my unsuccessful attempt:
AppsUnavailable = CALCULATE (
count(Builds[Build]),
CALCULATETABLE (
SUMMARIZE ( Builds,Builds[Status] ),
Builds[Status] <> "Complete"
))
Thanks in advance!
UPDATE
I've tried this, but the count isn't working, and also this DAX filters "Complete" statuses out of my actual results! Which i don't want. I only want to filter the "Complete" statuses out of my count measure....
AppsUnavailable =
CALCULATE (
COUNT ( Builds[Build] ),
FILTER (
ALL ( Builds[Build] ),
Builds[Build] = SELECTEDVALUE ( Builds[Build] )
),
FILTER (
ALL ( Builds[Status] ),
Builds[Status] <> "Complete"
)
)
UPDATE 2
I think I'm doing something fundamentally wrong. I've really dumbed it down to just find other 'Builds' with the same name, and it still only returns 1's!
AppsUnavailable =
CALCULATE (
COUNT ( Builds[Build] ),
FILTER (
ALL ( Builds[Build] ),
Builds[Build] = SELECTEDVALUE ( Builds[Build] )
)
)
UPDATE 3
This query (when testing on a single table (no joins) sample) produces this:
Build....App....Status......AppsOutstanding
Build1...App1...UAT.........1
Build1...App2...Complete....0
Build1...App2...UAT.........1
Build2...App1...Complete....0
Build2...App2...Complete....0
But i actually need this:
Build....App....Status......AppsOutstanding
Build1...App1...UAT.........2
Build1...App2...Complete....0
Build1...App2...UAT.........2
Build2...App1...Complete....0
Build2...App2...Complete....0
So Build1 has 2 Apps that are not complete.
I then need to look into why I'm getting all 1's in the 'live' environment. It must be to do with filtering on 2 tables as opposed to 1....
You can replace [The Build In This Row] with SELECTEDVALUE ( Builds[Build] ).
Try this:
AppsUnavailable =
CALCULATE (
COUNT ( Builds[App] ),
FILTER (
ALL ( Builds[Status], Builds[Build] ),
Builds[Build] = SELECTEDVALUE ( Builds[Build] )
&& Builds[Status] <> "Complete"
)
) + 0
powerBI Table visualization internal use SUMMARIZECOLUMNS which is removed row without data from the measure. You have 2 options:
-Right click on GroupBy Column -> "Show item with no data"
-Add +0 to calculation after the last parenthesis
UPDATE:
CALCULATE (
COUNT ( YourTable[App] ),
FILTER (
ALL ( YourTable[App], YourTable[Build], YourTable[Status] ),
YourTable[Build] = SELECTEDVALUE ( YourTable[Build] )
&& YourTable[Status] <> "Complete"
)
) + 0

Convert comma separated text to a list of numbers

In Power BI, I have created a DAX query created with a var giving comma-separated text using CONCATENATEX function.
Output like
Var = "1,2,3,4,5,6"
Now I want to search this var into my table column with syntax
Table[col] in {var}.
It is throwing an error.
I even tried converting the column to string with syntax
Convert(table[col], string) in {var}
The error is removed but the data doesn't match with column data.
I found this Power BI community thread that is essentially the same question.
The solution is to convert the string into a path object.
Here's the code from the link:
Measure 3 =
VAR mymeasure =
SUBSTITUTE ( [Measure], ",", "|" )
VAR Mylen =
PATHLENGTH ( mymeasure )
VAR mytable =
ADDCOLUMNS (
GENERATESERIES ( 1, mylen ),
"mylist", VALUE ( PATHITEM ( mymeasure, [Value] ) )
)
VAR mylist =
SELECTCOLUMNS ( mytable, "list", [mylist] )
RETURN
CALCULATE ( COUNTROWS ( Table1 ), Table1[ID] IN mylist )
There's a bit of redundancy in the above, so I'd probably condense it a bit and write it like this:
SomeMeasureFilteredByVar =
VAR PathVar = SUBSTITUTE ( [Var], ",", "|" )
VAR VarList =
SELECTCOLUMNS (
GENERATESERIES ( 1, PATHLENGTH ( PathVar ) ),
"Item", VALUE ( PATHITEM ( PathVar, [Value] ) )
)
RETURN
CALCULATE ( [SomeMeasure], 'Table'[ID] IN VarList )
Edit: To just create a calculated table, you can skip the last step:
TableFromString =
VAR PathVar = SUBSTITUTE ( "1,2,3,4,5,6", ",", "|" )
RETURN
SELECTCOLUMNS (
GENERATESERIES ( 1, PATHLENGTH ( PathVar ) ),
"Item", VALUE ( PATHITEM ( PathVar, [Value] ) )
)
Note that it is not possible to create a calculated table that is dynamically responsive to report filters and slicers. Materialized calculated tables are only calculated once when the data loads, not every time you adjust a filter or slicer.
Therefore, you can use a measure in the table instead of the string "1,2,3,4,5,6" but the table output will be the same regardless of what the measure returns within different filter contexts.

If it is the first date or last date use one aggregation; if any other day, use another aggregation

Let's assume I have the below dataset.
What I need to create the below matrix where if it is the beginning or month end, I aggregate A or B in Category 1 and calculate SUM but if it is any other day in a month but 1st or last, I am tagging A or B in Category 2 and calculate SUM. I guess I need to use SWITCH, don't I?
Edit in info from comments
Like to create 3 col:
isStart = IF ( main_table[date] = STARTOFMONTH ( main_table[date] ), 1, 0 )
isEnd = IF ( main_table[date] = ENDOFMONTH ( 'main_table'[date] ), 1, 0 )
in_between_date =
IF ( AND ( main_table[date] <> ENDOFMONTH ( 'main_table'[date] ),
main_table[date] <> STARTOFMONTH ( main_table[date] ) ), 1, 0 )
Then, create the columns with my categories, like
start_end =
IF ( OR ( NOT ( ISERROR ( SEARCH ( "A", main_table[code] ) ) ),
main_table[code] = "B" ),
"Category 1",
BLANK () )
and
in_between =
IF ( OR ( main_table[code] = "B", main_table[code] = "A" ), "Category 2", BLANK () )
But then, what should I use in switch/if ? = if(VALUES('main_table'[isStart]) = 1, then what?
You where on the right track but overcomplicated a bit. You only need one extra column "Category" giving for each row in what category the item falls.
Category =
IF (
startEnd[date] = STARTOFMONTH ( startEnd[date] )
|| startEnd[date] = ENDOFMONTH ( startEnd[date] );
"Category1";
"Category2"
)
table end result is:

Is there a way to dynamically switch which relationship is active in powerpivot (based on slicer selection)?

I have a fact table (MORT) and a dimension table (GEO) in PowerPivot (2016). There are two joins between the tables with two columns in MORT relating to one column in GEO. We can call one join RES and the other REG. I have a large number of measures and I want to allow the user to quickly change between seeing the measures using the RES and REG relationships - essentially I want to be able to switch the active relationship (referred to as switch in the code). This would probably be based on a detached slicer.
I have tried nesting an if statement and various ways of defining a variable to use in a CALCUATE but either have the error that USERELATIONSHIP can only be used in a calculate (in the case of the if) or that USERELATIONSHIP only accepts a column reference (in the case of the var).
IF STATEMENT
MEASURE:= CALCULATE(COUNT(MORT[ID]), GEO,
IF(LASTNONBLANK(SWITCH,1)="RES",
USERELATIONSHIP(MORT[RES], GEO[AREA]),
USERELATIONSHIP(MORT[REG], GEO[AREA]))
VAR
MEASURE:=
VAR switch = IF(LASTNONBLANK(Switch,1)="RES", MORT[RES], MORT[REG])
RETURN
CALCULATE(COUNT(MORT[ID]), GEO, USERELATIONSHIP(switch, GEO[AREA])
I could create every measure with an if statement at the start to check the value of switch but this creates a lot of duplicate code.
I want some way for the end user to change the active relationship in a measure but ideally without a lot of duplicated code.
How about like this?
MEASURE :=
IF (
LASTNONBLANK ( Switch, 1 ) = "RES",
CALCULATE ( COUNT ( MORT[ID] ), GEO, USERELATIONSHIP ( MORT[RES], GEO[AREA] ) ),
CALCULATE ( COUNT ( MORT[ID] ), GEO, USERELATIONSHIP ( MORT[REG], GEO[AREA] ) )
)
Edit:
In your comment, you said you tried this:
M :=
VAR calc =
FILTER ( MORT, MORT[CAUSE] >= "I" && 'Remake Data'[CAUSE] <= "I9" )
VAR select =
IF (
HASONEVALUE ( 'SWITCH'[Switch] ),
LASTNONBLANK ( 'SWITCH'[Switch], 1 ),
"ERROR"
)
RETURN
IF (
select = "RES",
CALCULATE ( COUNTROWS ( calc ), USERELATIONSHIP ( MORT[RES], GEO[Area] ) ),
IF (
selection = "REG",
CALCULATE ( COUNTROWS ( calc ), USERELATIONSHIP ( MORT[REG], GEO[Area] ) ),
"ERROR"
)
)
There are a few problems with this, but mainly, if you define something as a variable, then it's constant and won't be affected by other things within a CALCULATE. Try the following instead.
Define a new measure:
CountRowsMeasure =
COUNTROWS ( FILTER ( MORT, MORT[CAUSE] >= "I" && 'Remake Data'[CAUSE] <= "I9" ) )
Then use that measure within your M measure:
M =
VAR select = SELECTEDVALUE( 'SWITCH'[Switch], "ERROR" )
RETURN
SWITCH (
select,
"RES", CALCULATE ( [CountRowsMeasure], USERELATIONSHIP ( MORT[RES], GEO[Area] ) ),
"REG", CALCULATE ( [CountRowsMeasure], USERELATIONSHIP ( MORT[REG], GEO[Area] ) ),
"ERROR"
)