How do I add a AND to my SUMX() statement? My current code is:
Enquiry Excluded Amt =
SUMX (
FILTER ( _enquiries, _enquiries[_GUID] = _2018_Budget[_GUID] ),
_enquiries[Amount (Enq)]
)
But I want an AND statement added into the SUMX()
Enquiry Excluded Amt =
SUMX (
FILTER ( _enquiries, _enquiries[_GUID] = _2018_Budget[_GUID] ),
_enquiries[Amount (Enq)] AND _enquiries[Excluded] = TRUE()
)
The above doesn't work.
The syntax && allows for combining conditions in a filter. Like this, for example:
Enquiry Excluded Amt =
SUMX (
FILTER ( _enquiries,
_enquiries[_GUID] = _2018_Budget[_GUID] && _enquiries[Excluded] = TRUE()
),
_enquiries[Amount (Enq)]
)
Related
I'd like to know how to write this line bellow in DAX. I'm a beginner and I'm having a lot of problems trying to write this code in Dax to return the value I need.
(select
top 1 Payor.CompanyName
from Payor, PatientPayor
where PatientPayor.PatientSer = pat.PatientSer
and Payor.PayorSer = PatientPayor.PayorSer) as conv,
This is what I tried to do so far.
Convenio =
TOPN ( 1, VALUES ( Payor[CompanyName] ), PatientPayor[PatientSer] )
= FILTER ( Patient, PatientPayor[PatientSer] = Patient[PatientSer] )
I did solve it with the code bellow:
formula =
VAR currpayorSer =
SELECTEDVALUE ( PatientPayor[PayorSer] )
VAR currPatientSer =
SELECTEDVALUE ( PatientPayor[PatientSer] )
RETURN
CALCULATE (
MIN ( Payor[CompanyName] ),
FILTER ( ALLSELECTED ( Payor ), Payor[PayorSer] = currpayorSer ),
FILTER ( ALLSELECTED ( Patient ), Patient[PatientSer] = currPatientSer )
)
I want the values in between the years mentioned in the image and get their equivalent sales qty.
The sample data is:
Sample Data
For ex: If I select 2005 in the slicer, I should get the qty ordered as 4+5+6 =15 in the new column or as a measure.
Try with this code:
BetweenRange =
CALCULATE (
SUM ( 'Table'[Sales Qty] ),
FILTER (
ALL ( 'Table'[Start Year], 'Table'[End Year] ),
SELECTEDVALUE ( 'YourFilterTable'[Year] ) >= 'Table'[Start Year]
&& SELECTEDVALUE ( 'YourFilterTable'[Year] ) <= 'Table'[End Year]
)
)
I'd suggest using a variable to read in the slicer value:
SumQuantity =
VAR SelectedYear = SELECTEDVALUE ( Slicer[Year] )
RETURN
CALCULATE (
SUM ( Sales[Sales qty] ),
Sales[Start year] <= SelectedYear,
Sales[end Year] >= SelectedYear
)
I am trying to create a measure that will show booked revenue over time, grouped by a few categories. I also want to show as 0 within line charts when the data is BLANK(), so I have it in an IF statement. Everything works just fine except for whatever reason I cannot get it to only show dates prior to today.
Here is the current Measure:
M_BookedRevenue =
VAR CurrentAccountingYear =
CALCULATE ( MIN ( 'Date'[AccountingYear] ), 'Date'[Date] = TODAY () )
VAR CurrentDate =
CALCULATE ( MIN ( 'Date'[SortDate] ), 'Date'[Date] = TODAY() )
RETURN
CALCULATE (
IF (
ISBLANK (
SUMX (
FILTER (
GROUPBY (
RevenueChannel,
RevenueChannel[ChannelBucket],
RevenueChannel[Channel],
'Date'[Date],
'Date'[SortDate],
'Date'[AccountingWeek],
'Date'[WeekNumber],
'Date'[AccountingMonthEnglishAbbrYear],
'Date'[AccountingMonth],
'Date'[AccountingYear],
"Revenue", SUMX ( CURRENTGROUP (), RevenueChannel[TransactionRevenue] )
),
'Date'[AccountingYear] >= CurrentAccountingYear
&& 'Date'[SortDate] < CurrentDate
),
[Revenue]
)
),
0,
SUMX (
FILTER (
GROUPBY (
RevenueChannel,
RevenueChannel[ChannelBucket],
RevenueChannel[Channel],
'Date'[Date],
'Date'[SortDate],
'Date'[AccountingWeek],
'Date'[WeekNumber],
'Date'[AccountingMonthEnglishAbbrYear],
'Date'[AccountingMonth],
'Date'[AccountingYear],
"Revenue", SUMX ( CURRENTGROUP (), RevenueChannel[TransactionRevenue] )
),
'Date'[AccountingYear] >= CurrentAccountingYear
&& 'Date'[SortDate] < CurrentDate
),
[Revenue]
)
)
)
I will like to create a new column that calculates the percentage change from JAN-FEB-MAR-APR-MAY-JUN which are in the COLUMN "MONTH" based on the COLUMN "TOTAL".
Here is a script I have tried but its not working
change perc =
VAR ValueLastMONTH =
CALCULATE (
SUM ( Sheet1[TOTAL] ),
FILTER (
Sheet1,
Sheet1[MONTH]
= ( EARLIER ( Sheet1[MONTH] ) - 1 )
&&Sheet1 = EARLIER ( Sheet1[CATEGORY] )
)
)
RETURN
IF (
ISBLANK ( ValueLastMONTH ),
0,
( Sheet1[TOTAL] - ValueLastMONTH )
/ ValueLastMONTH
Here is the link to the power bi file. enter link description here
The Column 'Month' is not of type date. How would PowerBi know the text APR represents April? You need to make this column a date.
Now you need to change the script to work with DateDiff:
change perc =
VAR ValueLastMONTH =
CALCULATE (
SUM ( Sheet1[TOTAL] ),
FILTER (
Sheet1,
DATEDIFF(Sheet1[MONTH], EARLIER ( Sheet1[MONTH] ),MONTH) = 1
&& Sheet1[CATEGORY] = EARLIER ( Sheet1[CATEGORY] )
)
)
RETURN
IF (
ISBLANK ( ValueLastMONTH );
0;
( Sheet1[TOTAL] - ValueLastMONTH )
/ ValueLastMONTH)
I am trying to write a measure that will allow me to filter on statuscode and Datesbetween. With the filter, plus the two conditions, I have too many arguments for the FILTER function. What syntax can I use to get the desired result?
Won-Existing =
SUMX (
FILTER ( _enquiries,
_enquiries[_GUID] = _2018_Budget[_GUID] &&
_enquiries[statuscode] = 866120005 &&
DATESBETWEEN(_enquiries[Date Contract Awarded],DATE(2018,8,1),DATE(2018,8,31)
),
_enquiries[Amount (Enq)]
))
Looks like some parentheses mismatching to me. Try this:
Won-Existing =
SUMX (
FILTER ( _enquiries,
_enquiries[_GUID] = _2018_Budget[_GUID] &&
_enquiries[statuscode] = 866120005 &&
DATESBETWEEN(_enquiries[Date Contract Awarded], DATE(2018,8,1), DATE(2018,8,31))
),
_enquiries[Amount (Enq)]
)