Countif in Power BI - powerbi

I have a table in Power BI and looking to create a measure similar to Countif in Excel to count if Audit Rating contains Pass.
I have tried the below DAX but is failing as filter requires two arguments.
Pass Count = CALCULATE(COUNT('Export'[Audit Rating]),FILTER('Export'[Audit Rating] = "Pass"))

You came very close: Try this one:
Pass Count =
CALCULATE (
COUNT ( 'Export'[Audit Rating] ),
FILTER ( ALL ( 'Export'[Audit Rating] ), 'Export'[Audit Rating] = "Pass" )
)

Related

RANKX DAX not updating other graph

I've got the following DAX Measure that provides me with the ability to filter down to the last XX of activity from an individual.
I can only seem to add the measure to the Filter on Visual so when chosing to filter down on say the last 10 this does not update other visuals in the report.
What can I do so that I am able to view the last 10 activities, but for the other visuals to update?
Rank = RANKX
(ALLEXCEPT(Sheet1,Sheet1[Name]),
CALCULATE(MAX(Sheet1[Date])),,
DESC)
It's likely you are applying that filter to only one visual.
It's better to implement the logic in the DAX calculation.
DAX Calculation
Rank =
VAR _Calc =
RANKX (
ALLEXCEPT ( Sheet1, Sheet1[Name] ),
CALCULATE ( MAX ( Sheet1[Date] ) ),
,
DESC
)
RETURN
IF ( _Calc <= 10, _Calc )

How to count dates in Power BI DAX

I have a table like below.
I want to show count of LicenseEndDate. Like In my slicer I have taken WeekEnding column suppose if I select weekending date like 09/25/2022 then I want show the count of LicenseEndDate dates that are ended between 09/18/2022 to 09/25/2022. How to create measure for this. I want to show that count in card visual. I created a measure like below
License_Expired_Count = COUNT(Trade[LicenseEndDate]).
But It giving me count of all. That mean the License which are expiring in the feature count also it was showing. But want to show count of license which are expired in the selected period. How create measure for this.
Please check this code, let me know If It works for you.
License_Expired_Count =
CALCULATE (
COUNT ( Trade[LicenseEndDate] ),
Trade[LicenseEndDate] <= SELECTEDVALUE ( Trade[WeekEndingDate] ),
Trade[LicenseEndDate]
> SELECTEDVALUE ( Trade[WeekEndingDate] ) - 7
)
try this :
License_Expired_Count =
VAR _slt =
SELECTEDVALUE ( Trade[WeekEndingDate] )
RETURN
CALCULATE (
COUNT ( Trade[LicenseEndDate] ),
ALLSELECTED ( Trade[WeekEndingDate] ),
DATESBETWEEN ( Trade[LicenseEndDate], _slt - 7, _slt )
)
check sample file attached

I need to filter my table in Power BI with multi filter with "AND" logic

I'm new to Power BI and DAX Language.
I have a table that contains names, skills, and assessments. For example, like this:
In Power BI, I need to have two filters one by skill and other by assessment, to show me the name that I want:
For example: If I filter by skill =Python and assessment between 2 and 3, the result should be Name =A, not A, and C, what happened is output is considered that I have at least one result, that is Python.
Conclusion: I want to filter by skill (or all skills) AND by level (which can be ONE level or an interval). For default Power BI shows me OR not AND.
I try this DAX formula:
name with all skills =
CALCULATE (
COUNTROWS (
FILTER (
ADDCOLUMNS (
VALUES ( Assessments[corp id] );
"Skills"; CALCULATE (
COUNTROWS ( VALUES ( Assessments[skill] ) );
CALCULATETABLE ( Example )
)
);
[Skills] = COUNTROWS ( ALLSELECTED( Assessments[skill] ) )
)
);
ALLSELECTED (Assessments[skill] )
)
When you filter on multiple columns, Power BI combines the conditions using AND logic. Obviously, you don't want to use AND for the same column since, for example, Name can't be A and B simultaneously, so OR is used when selecting multiple values in a single column.

Power BI : why EARLIER() does not recognize date column?

I am trying to make a cumulative measure in Power BI as Following :
prices = SUM(Testing[price])
comulativetest = CALCULATE([prices],FILTER(Testing,EARLIER(Testing[Date])>=Testing[Date]))
but this error message appear to me
and this is the table
what's the problem with it, please?
Earlier is mostly used in the context of "calculated columns". I think you are trying to use it in a measure and that's why you are getting an error.
Create a "Dates" table, and create a (one-to-many) join between that and your "Testing" table. Then use a measure like this:
comulativetest :=
CALCULATE (
[prices],
FILTER (
ALL ( Dates ),
Dates[Date] <= MAX ( Dates[Date] )
)
)

How can i write excel formula in power BI dax

How can i write below formula in DAX in PBI
=IF(COUNTIF(C:C,C2)>1,C2,"-")
Above formula showcases that if count of any record is >1 then it should come in another column
Try this code:
=
IF (
COUNTROWS (
FILTER (
Table,
Table[Column] = EARLIER ( Table[Column] )
)
) > 1 ,
Table[Column],
"-"
)