Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and a 50 percent discount on exams.
Get startedEarn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
I would like to write a DAX to count the number of 'yes' as shown in the column [one-year@work], which is not in the data model and i would like to avoid creating a calculated column.
The DAX should check through the column [left] and find out if the date is 31.12 of the year (it could be any year 2018, 2019,...) or empty, both cases are to be evaluated as positive and counted. See my effort below. Thankful for any pointers and solutions ...
SWITCH (
TRUE ();
VALUES ( table[Position] ) = "worker"; CALCULATE (
CONTAINSSTRING ( data[Funktion]; "worker" );
ISBLANK ( data[left] ) OR NOT(ISBLANK(endofmonth(data[left])))
);
Solved! Go to Solution.
Hi @Anonymous ,
We can use the following measure to meet your requirement,
Measure =
SWITCH (
TRUE(),
MAX('Table'[Position]) = "worker",
CALCULATE (
CALCULATE(COUNT('Table'[Position]),'Table'[Position]="worker")
,FILTER('Table', ISBLANK('Table'[left]) || ENDOFYEAR('Table'[left]) = 'Table'[left]))
)
The result like this,
If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?
BTW, pbix as attached.
Best regards,
Community Support Team _ zhenbw
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous ,
We can use the following measure to meet your requirement,
Measure =
SWITCH (
TRUE(),
MAX('Table'[Position]) = "worker",
CALCULATE (
CALCULATE(COUNT('Table'[Position]),'Table'[Position]="worker")
,FILTER('Table', ISBLANK('Table'[left]) || ENDOFYEAR('Table'[left]) = 'Table'[left]))
)
The result like this,
If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?
BTW, pbix as attached.
Best regards,
Community Support Team _ zhenbw
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Not sure what this is counting and why you aren't using DATEDIFF, but could you try (as a MEASURE):
CountOneYr@Wk= COUNTROWS(FILTER(Table, ISBLANK(Table[left]) || ENDOFYEAR(Table[left]) = Table[left]))))
Has this post solved your problem? Please mark it as a solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos.
I work as a trainer and consultant for Microsoft 365, specialising in Power BI and Power Query.
https://sites.google.com/site/allisonkennedycv
Copying DAX from this post? Click here for a hack to quickly replace it with your own table names
Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C
I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com
@AllisonKennedy thanks for your quick respond. But it has to be done in a switch and calculate expression as i am working on a huge dashboard and dont want to change a lot.