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"
)
Related
I need help with a PowerBI error. I cannot display any data because of this error I've been receiving from DAX: dax comparison operations do not support comparing values of type text with values of type integer.
It appears that the error is in this part of the formula:
FILTER('tgv vDimWorkspaceArea', 'tgv vDimWorkspaceArea'[ValidFromKey] <= MaxSelectedDateKey && 'tgv vDimWorkspaceArea'[ValidToKey] >= MinSelectedDateKey),
FILTER('tgv vDimDeviceWorkspaceAreaParty', 'tgv vDimDeviceWorkspaceAreaParty'[ValidFromKey] <= MaxSelectedDateKey && 'tgv vDimDeviceWorkspaceAreaParty'[ValidToKey] >= MinSelectedDateKey)
I have checked the formats of the "ValidToKey" and "ValidFromKey", they are both in the format of Whole number in the table (e.g. 20220421).
Any ideas where else I should look?
Thank you
no it's not possible to get blank. The ValidTo and ValidFrom keys are in the format of date. I tried the rest of the formula via trial and error and it was working. When I inserted these filter queries it stopped working.
Here is the rest of the formula:
Index =
VAR MinSelectedDateKey = MIN('Calendar'[DateKey])
VAR MaxSelectedDateKey = MAX('Calendar'[DateKey])
RETURN
(
CALCULATE(
COUNTROWS('dm FactEnviroData_Agr60_new'),
FILTER(
'dm FactEnviroData_Agr60_new',
'dm FactEnviroData_Agr60_new'[ComfortCO2] = "High" && 'dm FactEnviroData_Agr60_new'[ComfortHumidity] = "High"
|| 'dm FactEnviroData_Agr60_new'[ComfortCO2] = "High" && 'dm FactEnviroData_Agr60_new'[ComfortHumidity] = "Medium"
),
FILTER('dm DimWorkspaceArea', 'dm DimWorkspaceArea'[ValidFromKey] <= MaxSelectedDateKey && 'dm DimWorkspaceArea'[ValidToKey] >= MinSelectedDateKey),
FILTER('dm DimDeviceWorkspaceAreaParty', 'dm DimDeviceWorkspaceAreaParty'[ValidFromKey] <= MaxSelectedDateKey && 'dm DimDeviceWorkspaceAreaParty'[ValidToKey] >= MinSelectedDateKey)
) + 0
) /
CALCULATE(
COUNTROWS('dm FactEnviroData_Agr60_new'),
'dm FactEnviroData_Agr60_new'[ComfortCO2] <> "null",
FILTER('dm DimWorkspaceArea', 'dm DimWorkspaceArea'[ValidFromKey] <= MaxSelectedDateKey && 'dm DimWorkspaceArea'[ValidToKey] >= MinSelectedDateKey),
FILTER('dm DimDeviceWorkspaceAreaParty', 'dm DimDeviceWorkspaceAreaParty'[ValidFromKey] <= MaxSelectedDateKey && 'dm DimDeviceWorkspaceAreaParty'[ValidToKey] >= MinSelectedDateKey)
)
*100
Check steps:
1.
CALCULATE(
COUNTROWS('dm FactEnviroData_Agr60_new'),
'dm FactEnviroData_Agr60_new'[ComfortCO2] <> "null"
,FILTER(
'dm DimWorkspaceArea'
,'dm DimWorkspaceArea'[ValidFromKey] <= MaxSelectedDateKey
&& 'dm DimWorkspaceArea'[ValidToKey] >= MinSelectedDateKey
)
,FILTER(
'dm DimDeviceWorkspaceAreaParty'
,'dm DimDeviceWorkspaceAreaParty'[ValidFromKey] <= MaxSelectedDateKey
&& 'dm DimDeviceWorkspaceAreaParty'[ValidToKey] >= MinSelectedDateKey)
)
CALCULATE(
COUNTROWS('dm FactEnviroData_Agr60_new'),
'dm FactEnviroData_Agr60_new'[ComfortCO2] <> "null"
)
COUNTROWS(
FILTER(
'dm DimWorkspaceArea'
,'dm DimWorkspaceArea'[ValidFromKey] <= MaxSelectedDateKey
&& 'dm DimWorkspaceArea'[ValidToKey] >= MinSelectedDateKey
)
)
COUNTROWS(
FILTER(
'dm DimWorkspaceArea'
,-- 'dm DimWorkspaceArea'[ValidFromKey] <= MaxSelectedDateKey
--&&
'dm DimWorkspaceArea'[ValidToKey] >= MinSelectedDateKey
)
)
COUNTROWS(
FILTER(
'dm DimWorkspaceArea'
,'dm DimWorkspaceArea'[ValidFromKey] <= MaxSelectedDateKey
-- && 'dm DimWorkspaceArea'[ValidToKey] >= MinSelectedDateKey
)
)
please can you let me know why these two measures produce different results? I am obv missing something simple to do with AND and OR. thank you.
measure 1 = CALCULATE (
COUNT ( fct_core[colour] ),
fct_core[type] = 1
|| fct_core[type] = 2
|| fct_core[type] = 3
&& fct_core[colour] = 5
|| fct_core[colour] = 6
|| fct_core[colour] = 7
|| fct_core[colour] = 8
)
measure 2 = CALCULATE (
COUNT ( fct_core[colour] ),
fct_core[type] >= 1
&& fct_core[type] <= 3
&& fct_core[colour] = 5
|| fct_core[colour] = 6
|| fct_core[colour] = 7
|| fct_core[colour] = 8
)
This is an order of operations misunderstanding.
If you put in appropriate parentheses, then these measures should be the same (assuming types only have integer values).
measure 1 =
CALCULATE (
COUNT ( fct_core[colour] ),
(
fct_core[type] = 1 ||
fct_core[type] = 2 ||
fct_core[type] = 3
)
&&
(
fct_core[colour] = 5 ||
fct_core[colour] = 6 ||
fct_core[colour] = 7 ||
fct_core[colour] = 8
)
)
measure 2 =
CALCULATE (
COUNT ( fct_core[colour] ),
(
fct_core[type] >= 1 &&
fct_core[type] <= 3
)
&&
(
fct_core[colour] = 5 ||
fct_core[colour] = 6 ||
fct_core[colour] = 7 ||
fct_core[colour] = 8
)
)
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
I have a requirement like this,
P.No. BR IND SC TD RM CD PD Out - Col - Required
1 B N T 2/1/2011 2/1/2011 5/1/2007 1/1/2007 1
1 B N T 2/1/2011 2/1/2011 5/1/2010 2/1/2011 1
1 B N T 2/1/2011 6/1/2019 5/1/2007 2/1/2011 0
1 B N T 2/1/2011 1/1/2019 5/1/2007 2/1/2011 0
THE Out-Col-Required is what I am trying to do using DAX - Calculated Column.
This is the Logic that it follows,
Filter the Table for the following first in DAX,
BR = B, IND = N, SC = T, TD = RM
Then identify the Min CD date and Max PD date for P.No.
if the diff is less than 30 months, then 1 else 0.
Kindly help me with this.
Thanks.
Out =
VAR PNo = OutCol[P.No.]
VAR filt =
FILTER (
OutCol;
OutCol[P.No.] = PNo
&& OutCol[TD] = OutCol[RM]
&& OutCol[BR] = "B"
&& OutCol[IND] = "N"
&& OutCol[SC] = "T"
)
VAR monthsDiff =
CALCULATE (
DATEDIFF (
MIN ( OutCol[CD] );
MAX ( OutCol[PD] );
MONTH
);
filt
)
RETURN
IF (
OutCol[TD] = OutCol[RM]
&& OutCol[BR] = "B"
&& OutCol[IND] = "N"
&& OutCol[SC] = "T"
&& monthsDiff < 30;
1;
0
)
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]
)