I am working in PowerBI and I have a dataset showing candidate movement within hiring requisitions. Via DAX, I would like to add columns that show the time difference between certain statuses. E.g., the result would show "3" down the column for "New to Hire" and so on.
You can do this using three measures. You will need to adjust Table3 to reflect your actual table name. I also assumed that there is a column that designates a unique ID for each employee.
New to Hire:
New to Hire :=
VAR CurID =
MAX ( Table3[ID] )
VAR NewDate =
CALCULATE (
FIRSTDATE ( Table3[Date] ),
FILTER ( ALL ( Table3 ), Table3[ID] = CurID && Table3[Status] = "New" )
)
VAR HireDate =
CALCULATE (
FIRSTDATE ( Table3[Date] ),
FILTER ( ALL ( Table3 ), Table3[ID] = CurID && Table3[Status] = "Hired" )
)
RETURN
DATEDIFF ( NewDate, HireDate, DAY )
Offer to Accept:
Offer to Acccept :=
VAR CurID =
MAX ( Table3[ID] )
VAR OfferDate =
CALCULATE (
FIRSTDATE ( Table3[Date] ),
FILTER ( ALL ( Table3 ), Table3[ID] = CurID && Table3[Status] = "Offer Sent" )
)
VAR AcceptDate =
CALCULATE (
FIRSTDATE ( Table3[Date] ),
FILTER ( ALL ( Table3 ), Table3[ID] = CurID && Table3[Status] = "Offer Accepted" )
)
RETURN
DATEDIFF ( OfferDate, AcceptDate, DAY )
Offer to Hire
Offer to Hire :=
VAR CurID =
MAX ( Table3[ID] )
VAR OfferDate =
CALCULATE (
FIRSTDATE ( Table3[Date] ),
FILTER ( ALL ( Table3 ), Table3[ID] = CurID && Table3[Status] = "Offer Sent" )
)
VAR HireDate =
CALCULATE (
LASTDATE ( Table3[Date] ),
FILTER ( ALL ( Table3 ), Table3[ID] = CurID && Table3[Status] = "Hired" )
)
RETURN
DATEDIFF ( OfferDate, HireDate, DAY )
Related
The following using wpdb->prepare returns empty results while the code below not using wpdb->prepare returns the correct results. What is wrong?
global $wpdb;
$query = $wpdb->prepare("select subid, firstname, lastname from wpks_members where member_id = %d,".$mid);
$row= $wpdb->get_row($query);
$query = $wpdb->prepare("select t.subid, t.testid, t.test_date, t.puzzle_score,t.clock_score,t.match_score,t.oddone_score,(t.puzzle_score+t.clock_score+t.match_score+t.oddone_score) as tot,
if((t.puzzle_score+t.clock_score+t.match_score+t.oddone_score) < 90, 'Yes', 'No') as refer, u.ufname, u.ulname
from wpks_results t
join wpks_hasi_users u on t.userid = u.userid
where t.member_id = %d,".$mid);
$rows = $wpdb->get_results($query);
//this below works
$row= $wpdb->get_row("select subid, firstname, lastname from wpks_members where member_id = ".$mid);
$query = $wpdb->prepare();
$rows = $wpdb->get_results("select t.subid, t.testid, t.test_date, t.puzzle_score,t.clock_score,t.match_score,t.oddone_score,(t.puzzle_score+t.clock_score+t.match_score+t.oddone_score) as tot,
if((t.puzzle_score+t.clock_score+t.match_score+t.oddone_score) < 90, 'Yes', 'No') as refer, u.ufname, u.ulname
from wpks_results t
join wpks_hasi_users u on t.userid = u.userid
where t.member_id = ".$mid);
It should be:
$query = $wpdb->prepare("select subid, firstname, lastname from wpks_members where member_id = %d", $mid);
I'm attempting to build a report in PeopleSoft's Query Manager that has future and current employees on it. I want to be able to find the employees who do not have leave plans, specifically 50 and 52. I thought I was on the right track with the following BUT after auditing my report it is bringing in people who HAVE 50 and 52. I think it has to do with the subquery (SQL below).
Here are some pictures of query manager:
SELECT DISTINCT B.COMPANY, A.EMPLID, A.NAME, B.FULL_PART_TIME, B.REG_TEMP, C.DESCR, D.PLAN_TYPE, (CASE WHEN B.REG_TEMP = 'T' THEN '' WHEN C.DESCR = 'Intern' THEN '' WHEN C.DESCR = 'PenFed Intern' THEN '' ELSE 'Check records/give Leave' END), CONVERT(CHAR(10),SUBSTRING(CONVERT(CHAR,GETDATE(),121), 1, 10),121)), (CONVERT(CHAR(10),SUBSTRING(CONVERT(CHAR,GETDATE(),121), 1, 10),121)), (CONVERT(CHAR(10),SUBSTRING(CONVERT(CHAR,GETDATE(),121), 1, 10),121))
FROM (PS_PERSONAL_DATA A LEFT OUTER JOIN (PS_LEAVE_PLAN D INNER JOIN PS_EMPLMT_SRCH_QRY D1 ON (D.EMPLID = D1.EMPLID AND D.EMPL_RCD = D1.EMPL_RCD AND D1.OPRID = 'XXXXXXXX' )) ON A.EMPLID = D.EMPLID ), PS_PFC_JOB_VW B, PS_JOBCODE_TBL C, PS_SET_CNTRL_REC C2
WHERE ( C.JOBCODE = B.JOBCODE
AND C2.SETCNTRLVALUE = B.BUSINESS_UNIT
AND C2.RECNAME = 'JOBCODE_TBL'
AND C2.SETID = C.SETID
AND ( A.EMPLID = B.EMPLID
AND ( B.EFFDT =
(SELECT MAX(B_ED.EFFDT) FROM PS_PFC_JOB_VW B_ED
WHERE B.EMPLID = B_ED.EMPLID
AND B.EMPL_RCD = B_ED.EMPL_RCD
AND B_ED.EFFDT <= SUBSTRING(CONVERT(CHAR,GETDATE(),121), 1, 10))
AND B.EFFSEQ =
(SELECT MAX(B_ES.EFFSEQ) FROM PS_PFC_JOB_VW B_ES
WHERE B.EMPLID = B_ES.EMPLID
AND B.EMPL_RCD = B_ES.EMPL_RCD
AND B.EFFDT = B_ES.EFFDT)
OR ( B.EFFDT =
(SELECT MIN(B_ED.EFFDT) FROM PS_PFC_JOB_VW B_ED
WHERE B.EMPLID = B_ED.EMPLID
AND B.EMPL_RCD = B_ED.EMPL_RCD
AND B_ED.EFFDT >= SUBSTRING(CONVERT(CHAR,GETDATE(),121), 1, 10))
AND B.EFFSEQ =
(SELECT MAX(B_ES.EFFSEQ) FROM PS_PFC_JOB_VW B_ES
WHERE B.EMPLID = B_ES.EMPLID
AND B.EMPL_RCD = B_ES.EMPL_RCD
AND B.EFFDT = B_ES.EFFDT)
AND B.ACTION IN ('HIR','REH','REI')))
AND B.EMPL_STATUS IN ('A','L','P')
AND B.PER_ORG = 'EMP'
AND C.EFFDT =
(SELECT MAX(C_ED.EFFDT) FROM PS_JOBCODE_TBL C_ED
WHERE C.SETID = C_ED.SETID
AND C.JOBCODE = C_ED.JOBCODE
AND C_ED.EFFDT <= B.EFFDT)
AND A.EMPLID NOT IN (SELECT E.EMPLID
FROM PS_LEAVE_PLAN E, PS_EMPLMT_SRCH_QRY E1
WHERE E.EMPLID = E1.EMPLID
AND E.EMPL_RCD = E1.EMPL_RCD
AND E1.OPRID = 'XXXXXXXX'
AND ( E.EFFDT =
(SELECT MAX(E_ED.EFFDT) FROM PS_LEAVE_PLAN E_ED
WHERE E.EMPLID = E_ED.EMPLID
AND E.EMPL_RCD = E_ED.EMPL_RCD
AND E.PLAN_TYPE = E_ED.PLAN_TYPE
AND E.BENEFIT_NBR = E_ED.BENEFIT_NBR
AND E_ED.EFFDT <= SUBSTRING(CONVERT(CHAR,GETDATE(),121), 1, 10))
AND ( E.PLAN_TYPE = '50'
OR E.PLAN_TYPE = '52') )) ))
Where am I going wrong here?
I have removed pagination conditions from my wordpress page but it is still showing limited results and i want to show all results.
This is my originial code :
$seller_id = get_current_user_id();
$order_status = isset( $_GET['order_status'] ) ? sanitize_key( $_GET['order_status'] ) : 'all';
$pages = explode('/',$_SERVER['REQUEST_URI']);
if(isset($pages) && $pages[4]!=''){ $paged = $pages[4]; }else{ $paged = 1;}
$limit = 10;
$offset = ( $paged - 1 ) * $limit;
$user_orders = dokan_get_seller_orders( $seller_id, $order_status, $limit, $offset );
and this is my modified code, it is still only showing 10 results :
$seller_id = get_current_user_id();
$order_status = isset( $_GET['order_status'] ) ? sanitize_key( $_GET['order_status'] ) : 'all';
$user_orders = dokan_get_seller_orders( $seller_id, $order_status);
It can be done using :
$order_count = dokan_get_seller_orders_number( $seller_id, $order_status );
$limit = $order_count;
$offset = 0;
$user_orders = dokan_get_seller_orders( $seller_id, $order_status, $limit, $offset );
My website's post have one, two, three etc categories depends on articles. My menu is made of categories. when i select post (open whole article) it shows post category in menu.
Problem : when i select such article who have two category that time menu shows two selection of menus. how can i show only one category (first category)?
In above image you can see that when i select some post who have two category that time two menu selected.
Shall do changes in function.php, nav-menu-template.php or anywhere else....
foreach ( (array) $menu_items as $key => $menu_item ) {
$menu_items[$key]->current = false;
$classes = (array) $menu_item->classes;
$classes[] = 'menu-item';
$classes[] = 'menu-item-type-' . $menu_item->type;
$classes[] = 'menu-item-object-' . $menu_item->object;
// if the menu item corresponds to a taxonomy term for the currently-queried non-hierarchical post object
if ( $wp_query->is_singular && 'taxonomy' == $menu_item->type && in_array( $menu_item->object_id, $possible_object_parents ) ) {
$active_parent_object_ids[] = (int) $menu_item->object_id;
$active_parent_item_ids[] = (int) $menu_item->db_id;
$active_object = $queried_object->post_type;
// if the menu item corresponds to the currently-queried post or taxonomy object
} elseif (
$menu_item->object_id == $queried_object_id &&
(
( ! empty( $home_page_id ) && 'post_type' == $menu_item->type && $wp_query->is_home && $home_page_id == $menu_item->object_id ) ||
( 'post_type' == $menu_item->type && $wp_query->is_singular ) ||
( 'taxonomy' == $menu_item->type && ( $wp_query->is_category || $wp_query->is_tag || $wp_query->is_tax ) && $queried_object->taxonomy == $menu_item->object )
)
) {
$classes[] = 'current-menu-item';
$menu_items[$key]->current = true;
$_anc_id = (int) $menu_item->db_id;
while(
( $_anc_id = get_post_meta( $_anc_id, '_menu_item_menu_item_parent', true ) ) &&
! in_array( $_anc_id, $active_ancestor_item_ids )
) {
$active_ancestor_item_ids[] = $_anc_id;
}
if ( 'post_type' == $menu_item->type && 'page' == $menu_item->object ) {
// Back compat classes for pages to match wp_page_menu()
$classes[] = 'page_item';
$classes[] = 'page-item-' . $menu_item->object_id;
$classes[] = 'current_page_item';
}
$active_parent_item_ids[] = (int) $menu_item->menu_item_parent;
$active_parent_object_ids[] = (int) $menu_item->post_parent;
$active_object = $menu_item->object;
// if the menu item corresponds to the currently-requested URL
} elseif ( 'custom' == $menu_item->object ) {
$_root_relative_current = untrailingslashit( $_SERVER['REQUEST_URI'] );
$current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_root_relative_current );
$raw_item_url = strpos( $menu_item->url, '#' ) ? substr( $menu_item->url, 0, strpos( $menu_item->url, '#' ) ) : $menu_item->url;
$item_url = untrailingslashit( $raw_item_url );
$_indexless_current = untrailingslashit( preg_replace( '/' . preg_quote( $wp_rewrite->index, '/' ) . '$/', '', $current_url ) );
if ( $raw_item_url && in_array( $item_url, array( $current_url, $_indexless_current, $_root_relative_current ) ) ) {
$classes[] = 'current-menu-item';
$menu_items[$key]->current = true;
$_anc_id = (int) $menu_item->db_id;
while(
( $_anc_id = get_post_meta( $_anc_id, '_menu_item_menu_item_parent', true ) ) &&
! in_array( $_anc_id, $active_ancestor_item_ids )
) {
$active_ancestor_item_ids[] = $_anc_id;
}
if ( in_array( home_url(), array( untrailingslashit( $current_url ), untrailingslashit( $_indexless_current ) ) ) ) {
// Back compat for home link to match wp_page_menu()
$classes[] = 'current_page_item';
}
$active_parent_item_ids[] = (int) $menu_item->menu_item_parent;
$active_parent_object_ids[] = (int) $menu_item->post_parent;
$active_object = $menu_item->object;
// give front page item current-menu-item class when extra query arguments involved
} elseif ( $item_url == $front_page_url && is_front_page() ) {
//$classes[] = 'current-menu-item';
}
if ( untrailingslashit($item_url) == home_url() )
$classes[] = 'menu-item-home';
}
// back-compat with wp_page_menu: add "current_page_parent" to static home page link for any non-page query
if ( ! empty( $home_page_id ) && 'post_type' == $menu_item->type && empty( $wp_query->is_page ) && $home_page_id == $menu_item->object_id )
$classes[] = 'current_page_parent';
$menu_items[$key]->classes = array_unique( $classes );
}
`
Yes, Finally i had done it. I done changes in nav-menu-template.php.
I created one variable and initialized with 1 above
foreach ( (array) $menu_items as $key => $parent_item ) {
this code.
and add conditional code
if($repetation == '1'){//to stop second selection of menu
$classes[] = 'current-menu-parent';
$menu_items[$key]->current_item_parent = true;
$repetation++;
}
else{
//echo $repetation;
}
inbetween
if ( in_array( $parent_item->db_id, $active_parent_item_ids ) ) {
...}
this.
whole code look like
$repetation = '1';
// set parent's class
foreach ( (array) $menu_items as $key => $parent_item ) {
$classes = (array) $parent_item->classes;
$menu_items[$key]->current_item_ancestor = false;
$menu_items[$key]->current_item_parent = false;
if (
isset( $parent_item->type ) &&
(
// ancestral post object
(
'post_type' == $parent_item->type &&
! empty( $queried_object->post_type ) &&
is_post_type_hierarchical( $queried_object->post_type ) &&
in_array( $parent_item->object_id, $queried_object->ancestors ) &&
$parent_item->object != $queried_object->ID
) ||
// ancestral term
(
'taxonomy' == $parent_item->type &&
isset( $possible_taxonomy_ancestors[ $parent_item->object ] ) &&
in_array( $parent_item->object_id, $possible_taxonomy_ancestors[ $parent_item->object ] ) &&
(
! isset( $queried_object->term_id ) ||
$parent_item->object_id != $queried_object->term_id
)
)
)
) {
$classes[] = empty( $queried_object->taxonomy ) ? 'current-' . $queried_object->post_type . '-ancestor' : 'current-' . $queried_object->taxonomy . '-ancestor';
}
if ( in_array( intval( $parent_item->db_id ), $active_ancestor_item_ids ) ) {
$classes[] = 'current-menu-ancestor';
$menu_items[$key]->current_item_ancestor = true;
}
if ( in_array( $parent_item->db_id, $active_parent_item_ids ) ) {
if($repetation == '1'){//to stop second selection of menu
$classes[] = 'current-menu-parent';
$menu_items[$key]->current_item_parent = true;
$repetation++;
}
else{
//echo $repetation;
}
}
if ( in_array( $parent_item->object_id, $active_parent_object_ids ) )
$classes[] = 'current-' . $active_object . '-parent';
if ( 'post_type' == $parent_item->type && 'page' == $parent_item->object ) {
// Back compat classes for pages to match wp_page_menu()
if ( in_array('current-menu-parent', $classes) )
$classes[] = 'current_page_parent';
if ( in_array('current-menu-ancestor', $classes) )
$classes[] = 'current_page_ancestor';
}
$menu_items[$key]->classes = array_unique( $classes );
}
Ok... I got another WP problem now.
For my WP theme, i have some special things. For example, i have a table containing some stuff.
when i insert (in this case update) to this table i use $wpdb, like the code below:
$sql = $wpdb->prepare("UPDATE $table_name SET
`title` = '$title',
`text` = '$text',
`image` = '$image',
`thumbnail` = '$thumb',
`show` = $sql_show,
`order` = $order,
`language` = '$language',
`type` = '$type'
WHERE `id` = $id
;");
$wpdb->query($sql);
I have also tried this:
$sql = $wpdb->prepare("UPDATE $table_name SET
`title` = %s,
`text` = %s',
`image` = %s,
`thumbnail` = %s,
`show` = %d,
`order` = %d,
`language` = %s,
`type` = %s
WHERE `id` = $id
;", $title, $text, $image, $thumb, $show, $order, $language, $type);
Both of them works, EXCEPT when the $text contains a "%". If it contains this, the $sql is blank. Of coure i could change all the "%" to "percent", but that resolution is not acceptable! ;)
% has to be escaped with a percent, so replace a single percent with a double percent in $text: $text = str_replace('%', '%%', $text)