We use a report that makes a reference (via active table relationship) to a specific table. It is necessary to deactivate this relationship to properly calculate a value in a visual. However, when I deactivate this relationship it causes MANY (near 100) other items to break. I am able to apply formula fixes to these "broken" visuals by using the USERELATIONSHIP function.
My question is "In place of changing formulas in many places, Is there an ANTI version (or usage) of USERELATIONSHIP that I only apply in one location to apply a fix to a single visual)
I've tried to create a table that includes the matching date values that are related and that does mitigate my issue.
Additionally, this project has patient health information and I wouldn't be able to share a version of the file.
MJLT Total Lives =
CALCULATE(COUNT(Lives[mem_id1])
,
Filter (Lives,
(
Lives[meme_eff] <= MAX('Calendar'[Date])
&&
Lives[clip_eff] <= MAX('Calendar'[Date])
&&
Lives[meme_trm] >= min('Calendar'[Date])
&&
Lives[clip_trm] >= min('Calendar'[Date])
&&
Lives[cli_trm] >= min('Calendar'[Date])
&&
Lives[meme_eff] <= Lives[meme_trm])
)
) +0
{MJLT Total Lives =
CALCULATE(COUNT(Lives[mem_id1])
,
ALL(lives)
,
all(Claims)
,
ALL(ClientIDs)
,
all('Calendar')
,
Filter (Lives,
(
Lives[meme_eff] <= MAX('Calendar'[Date])
&&
Lives[clip_eff] <= MAX('Calendar'[Date])
&&
Lives[meme_trm] >= min('Calendar'[Date])
&&
Lives[clip_trm] >= min('Calendar'[Date])
&&
Lives[cli_trm] >= min('Calendar'[Date])
&&
Lives[meme_eff] <= Lives[meme_trm])
)
) +0
Related
suppose i have 4 parameters eg distance , head count , travellers and country score. what i want to do is if distance<=5 && head count <=20 && travellers <=30 && country score <=1 , then we should get value "VERY LOW".
Try with SWITCH function.
https://dax.guide/switch/
SomeMeasure = SWITCH( TRUE(),
Table[distance]<=5 && Table[head count] <=20 && Table[travellers] <=30 && Table[country score] <=1 , "VERY LOW",
Table[distance <= 10 && Table[Head count] <= 40 && Table[[travellers] <= 60 && Table[country score] <=2 , "LOW",
"NORMAL"
)
I have a report that fetches weekly data. I have a weeks table that contains the weeks and dates and relationships set up with the below tables.
I have a QueueSummary table;
I have ConciergeHours table;
The concierge hours differ from day to day, so i keep the start and finish time in a table so we can update it dynamically.
I am trying to create a measure to calculate how many interactions we have had, between the hours in the ConciergeHours table. Keep in mind this is a weekly report, so on any given day during the week, the hours may be different.
The calculation we are after is;
Number interactions accepted on queue LinkConciergeVQ (QueueSummary table) between the starthour and endhour in ConciergeHours table MINUS Number interactions offered on queue LinkVQ (QueueSummary table) between the starthour and endhour in ConciergeHours table
I currently have the measure looking like this. It works, but the between hours are not respected correctly, which i understand would be a result of the MIN, MAX.
m_deflections =
CALCULATE (
SUM ( QueueSummary[s_accepted] ),
QueueSummary[queue] = "LinkConciergeVQ",
filter(QueueSummary, [hour] >= min(ConciergeHours[starthour])),
filter(QueueSummary, [hour] < max(ConciergeHours[endhour]))
)
- CALCULATE (
SUM ( QueueSummary[s_offered] ),
QueueSummary[queue] = "LinkVQ",
filter(QueueSummary, [hour] >= min(ConciergeHours[starthour])),
filter(QueueSummary, [hour] < max(ConciergeHours[endhour]))
)
I hope i've explained this correctly.
If anyone could offer any help!?
Thanks so much
Not sure I understand your table relationships, but if its 1:* from ConciergeHours to QueueSummary via date then I think you can use this measure, or at least it puts you on the right track, I hope:
m_deflections =
var s_accept =
SUMX(
'ConciergeHours',
var startH = 'ConciergeHours'[startHour]
var endH = 'ConciergeHours'[endHour]
return
CALCULATE(
SUM('QueueSummary'[s_accepted]),
'QueueSummary'[hour] >= startH && 'QueueSummary'[hour] < endH
)
)
var s_offered =
SUMX(
'ConciergeHours',
var startH = 'ConciergeHours'[startHour]
var endH = 'ConciergeHours'[endHour]
return
CALCULATE(
SUM('QueueSummary'[s_offered]),
'QueueSummary'[hour] >= startH && 'QueueSummary'[hour] < endH
)
)
return
s_accepted - s_offered
I would collapse the 2 pairs of FILTER functions into a single FILTER for each CALCULATE. That will apply the filters against starthour and endhour in combination (the && means AND), where I expect they are currently applying as OR logic so not having any effect.
Along the lines of this:
m_deflections =
CALCULATE (
SUM ( QueueSummary[s_accepted] ),
QueueSummary[queue] = "LinkConciergeVQ",
FILTER (
QueueSummary,
[hour] >= MIN ( ConciergeHours[starthour] )
&& [hour] < MAX ( ConciergeHours[endhour] )
)
)
- CALCULATE (
SUM ( QueueSummary[s_offered] ),
QueueSummary[queue] = "LinkVQ",
FILTER (
QueueSummary,
[hour] >= MIN ( ConciergeHours[starthour] )
&& [hour] < MAX ( ConciergeHours[endhour] )
)
)
I want to show this year store count based on to date and from date.The following code is throwing this error when i am placing this column in table.
ThisYearStoreCount =
IF (
[DateDiff] > 365,
0,
IF (
DATESBETWEEN ( WUSA_CAL_DIM[End_Date], [From_Date], [To_Date] ),
DISTINCTCOUNTNOBLANK ( WUSA_STORE_DIM[Store Code] )
)
)
#RADO is spot on,
If I understand your logic, something like this should work.
ThisYearStoreCount =
IF (
[DateDiff] > 365,
0,
IF (
[From_Date] >= WUSA_CAL_DIM[End_Date]
&& [To_Date] <= WUSA_CAL_DIM[End_Date]
&& WUSA_STORE_DIM[Store Code] <> BLANK(),
1
)
)
That error usually means that you're using a function that returns a set of data, in a column context ( column contexts only allow a single value to exist per row ).
I'm reading between the lines a little bit, but the new column formula above will check if the end date is between the From_Date and To_Date before allowing the number 1 through.
Then you can just add the ThisYearStoreCount to any visual and it will sum wherever appropriate.
Your existing code should work as a measure ( instead of a column ) I think but it's impossible to tell without more information.
I am trying to convert a piece of SQL to dax.
It only involves two tables, both facts and a common dimension attribute, Encounter.
I want to sum all charges by encounter and sum collections by encounter, filtered to only collections of TransactionRollup_Name = Contractual, TransactionTypeDescription = Adjustment, posted last month.
I will filter the System and Action <> Delete in the reporting client (powerbi or excel)
Once these are obtained I want the sum of contractual collections where the portion of contractual collections over total encounter charges is >= .9 and < 1
SQL:
DECLARE #startdate INT = 20181201
, #thrudate INT = 20181231
, #systemcode VARCHAR(1) = '1';
SELECT SUM(coll.Contractual)
FROM ( SELECT SUM(Amount) * -1 Contractual
, col.EncounterID
FROM
dwo.FactCollections col
JOIN dwo.DimTransactionCode_mds mds ON col.mds_TransactionID = mds.SK_TransactionKey
WHERE
mds.TransactionRollup_Name = 'Contractual'
AND mds.TransactionTypeDescription = 'Adjustment'
AND col.SystemID = TRY_CONVERT(INT, #systemcode)
AND col.Action <> 'Delete'
AND col.PostDateTime >= #startdate
AND col.PostDateTime <= #thrudate
GROUP BY col.EncounterID ) coll
JOIN ( SELECT EncounterID
, SUM(Amount) Charge
FROM dwo.FactCharges ldg
WHERE
ldg.SystemID = TRY_CONVERT(INT, #systemcode)
AND ldg.Action <> 'Delete'
GROUP BY ldg.EncounterID ) chg ON chg.EncounterID = coll.EncounterID
WHERE
chg.Charge <> 0
AND chg.Charge IS NOT NULL
AND coll.Contractual / chg.Charge >= .90
AND coll.Contractual / chg.Charge < 1.0;
Attempted Dax Measure:
90%-99.99% of Charges :=
CALCULATE (
'MeasureTable'[Sum of Contractual Adjustments],
FILTER (
'FactCollections',
DIVIDE (
'MeasureTable'[Sum of Contractual Adjustments],
'MeasureTable'[ChargeTotal]
)
>= .90
&& DIVIDE (
'MeasureTable'[Sum of Contractual Adjustments],
'MeasureTable'[ChargeTotal]
)
< 1.0
)
)
Charge := SUM ( 'FactCharges'[Amount] )
Sum of Contractual Adjustments :=
CALCULATE (
SUM ( FactCollections[Amount] ) * ( -1 ),
FILTER (
'Transaction Code',
'Transaction Code'[TransactionTypeDescription] = "Adjustment"
&& 'Transaction Code'[TransactionRollup_Name] = "Contractual"
)
)
Sample data on one encounter, per request.
Addendum
Going a different route with the dax, this gets me 1/2 way.
The summarizecolumns query gets me a result set that aggregates both charges and contractual collections up to the encounter and calculates the ratio of contractuals / charges.
The end result would need to filter this intermediate result set where
contractual / charge ratio is >= .9 and < 1
post dates for contractual collections should be filtered by reporting client filter context
All post dates for charges should be included, regardless of the post date filter context in the reporting client
I have no idea how to do that second part in dax though.
> EVALUATE SUMMARIZECOLUMNS (
> 'Encounter'[Encounter],
> "ChargeAmount", SUMX ( 'FactCharges', 'FactCharges'[Sum Charge Amount] ),
> "ContractualAmount", SUMX (
> 'FactCollections',
> CALCULATE (
> 'FactCollections'[Sum of Adjustments],
> 'Transaction Code'[TransactionRollup_Name] = "Contractual"
> )
> ),
> "Contractual : Charge", DIVIDE (
> SUMX (
> 'FactCollections',
> CALCULATE (
> 'FactCollections'[Sum of Adjustments] * -1,
> 'Transaction Code'[TransactionRollup_Name] = "Contractual"
> )
> ),
> SUMX ( 'FactCharges', 'FactCharges'[Sum Charge Amount] )
> ) )
I am trying to sum an amount column based on p_region, statuscode, date range and dollar amount.*
When I try with CALCULATE(SUM()), I cannot get all the clauses that I need.
<£50k =
CALCULATE (
SUM ( tsg_enquiries[tsg_quoteprice_base] ),
tsg_enquiries[statuscode] = 866120000
|| tsg_enquiries[statuscode] = 866120007,
tsg_enquiries[tsg_quoteprice_base] <= 49999
)
The above is missing the date range clause.
tsg_enquiries[createdon] >= 'LTM Live'[xxxBegin] &&`
tsg_enquiries[createdon] <= 'LTM Live'[xxxEnd]`
When I try SUMX(), I cannot evaluate the amount.
£ALL =
SUMX (
FILTER (
tsg_enquiries,
tsg_enquiries[pc_regionno] = 'LTM Live'[pc_regionno]
&& tsg_enquiries[statuscode] = 866120000
|| tsg_enquiries[statuscode] = 866120007
&& tsg_enquiries[statuscode] = 'LTM Live'[pc_regionno]
&& tsg_enquiries[createdon] >= 'LTM Live'[xxxBegin]
&& tsg_enquiries[createdon] <= 'LTM Live'[xxxEnd]
),
tsg_enquiries[tsg_quoteprice_base]
)
The above is missing the amount clause.
tsg_enquiries[tsg_quoteprice_base]<=49999
How can I get my desired result?
If you use complex conditions in filter function, every condition should act on only one column. You could use CalculateTable function, may be. The follows is an example:
SUMX( CALCULATETABLE('InternetSales_USD', 'DateTime'[CalendarYear]=2002)
, [SalesAmount_USD])
If I understand correctly, you're trying to add tsg_enquiries[tsg_quoteprice_base]<=49999 to the criteria in your second query (that uses SUMX)? You can use the AND function, with the initial set of filters as the first argument and tsg_enquiries[tsg_quoteprice_base]<=49999 as the second. While not necessary, you may also want to considered replacing the && and || for readability.
£ALL =
SUMX (
FILTER (
tsg_enquiries,
AND (
tsg_enquiries[pc_regionno] = 'LTM Live'[pc_regionno]
&& tsg_enquiries[statuscode] = 866120000
|| tsg_enquiries[statuscode] = 866120007
&& tsg_enquiries[statuscode] = 'LTM Live'[pc_regionno]
&& tsg_enquiries[createdon] >= 'LTM Live'[xxxBegin]
&& tsg_enquiries[createdon] <= 'LTM Live'[xxxEnd],
tsg_enquiries[tsg_quoteprice_base] <= 49999
)
),
tsg_enquiries[tsg_quoteprice_base]
)