The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hi,
I have the following DAX:
RegSubmittedNoAccept/Reject =
CALCULATE(
DISTINCTCOUNT(vw_FT_Company_Registration_BI[company_id]),
vw_FT_Company_Registration_BI[RegistrationLog_Action] = "RegistrationSubmitted",
NOT vw_FT_Company_Registration_BI[company_id] IN CALCULATETABLE(
VALUES(vw_FT_Company_Registration_BI[company_id]),
vw_FT_Company_Registration_BI[RegistrationLog_Action] <> "RegistrationSubmitted"
)
)
I get a value of 250 from this, which seems correct, but when I create a table with companyname and this measure as another column, it returns 250 for every row (company) when I need to create a table that only includes the companies included in the measure. I have a 'Company' table which has company_id and companyname, where there is a relationship between this table and the 'Company' tables company_id.
How do I change the measure so I can get the companies included in this measure? Thank you.
It seems that the measure you have created is returning the same value for every row because it is not taking into account the context of the company name. In order to get the desired result, you need to modify your measure so that it takes into account the company name context.
One way to do this is to use the `ALLEXCEPT` function in your measure. This function removes all context filters in the table except filters that have been applied to the specified columns. Here's an example of how you could modify your measure:
```
RegSubmittedNoAccept/Reject =
CALCULATE(
DISTINCTCOUNT(vw_FT_Company_Registration_BI[company_id]),
ALLEXCEPT(Company, Company[companyname]),
vw_FT_Company_Registration_BI[RegistrationLog_Action] = "RegistrationSubmitted",
NOT vw_FT_Company_Registration_BI[company_id] IN CALCULATETABLE(
VALUES(vw_FT_Company_Registration_BI[company_id]),
vw_FT_Company_Registration_BI[RegistrationLog_Action] <> "RegistrationSubmitted"
)
)
```
This should give you the desired result where the measure only returns values for companies included in the measure. I hope this helps! Let me know if you have any further questions. 😊
User | Count |
---|---|
15 | |
8 | |
6 | |
6 | |
5 |
User | Count |
---|---|
25 | |
13 | |
12 | |
8 | |
8 |