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 currently have two tables set up on Power BI Desktop. The fact table contains duplicate rows of Case IDs and looks like the below -
Case ID ProcessOutcomeDateTime Error1.1 Error1.2 Error 2.1 Error2.2
Case1 01/01/23 1 0 1 0
Case1 02/01/23 1 0 1 0
Case2 3/02/23 0 0 1 0
Case2 4/02/23 0 0 1 0
There are more columns than these containing other attributes, hence I cannot just remove duplicates here.
As I am using calculations based off a case ID's Min Process Outcome Date Time, I created a calculated table that returns distinct case IDs with the Min Process Outcome Date Time:
Case ID Min ProcessOutcomeDateTime Total Errors Error1 Error2
Case1 01/01/23 2 1 1
Case2 3/02/23 1 0 1
Note: Key linking this table to fact table is Case ID.
In this calculated table, I created calculated columns to group my error codes into categories and to calculate total errors. Note these are all based off distinct case IDs and on its min process outcome date time.
The issue I'm having is creating a measure for Total Errors to bring it into my visualisation. Currently my table visualisation contains measures that refer to the Fact Table.
This is what I came up with but it's returning an error -
# Errors M =
var caseidvar = CALCULATE(VALUES('CALCTABLE'[caseid]))
var caseidvar2 = CALCULATE(VALUES('FACTTABLE'[caseid]))
var processdate = CALCULATE(VALUES('CALCTABLE'Min Process Outcome Date Time]))
var processdate2 = CALCULATE(VALUES('FACTTABLE'[Process Outcome Date Time]))
return
CALCULATE(MIN('CALCTABLE'[Total Errors]), FILTER(RELATEDTABLE(FACTTABLE), caseidvar = caseidvar2 && processdate = processdate2))
Any help will be appreciated - I've been stuck on this for days!
Thank you in advance
Solved! Go to Solution.
Hi @lynnpowerbi ,
Please try this measure.
# Errors M =
VAR caseidvar =
VALUES ( 'CALCTABLE'[Case ID] )
VAR processdate =
VALUES ( 'CALCTABLE'[Min ProcessOutcomeDateTime] )
RETURN
CALCULATE (
MIN ( 'CALCTABLE'[Total Errors] ),
'FACTTABLE'[Case ID] IN caseidvar
&& 'FACTTABLE'[ProcessOutcomeDateTime] IN processdate,
CROSSFILTER('CALCTABLE'[Case ID],'FACTTABLE'[Case ID],Both)
)
If I have misunderstood your needs, please feel free to contact us with the expected output.
Best Regards,
Gao
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum
Hi @lynnpowerbi ,
Please try this measure.
# Errors M =
VAR caseidvar =
VALUES ( 'CALCTABLE'[Case ID] )
VAR processdate =
VALUES ( 'CALCTABLE'[Min ProcessOutcomeDateTime] )
RETURN
CALCULATE (
MIN ( 'CALCTABLE'[Total Errors] ),
'FACTTABLE'[Case ID] IN caseidvar
&& 'FACTTABLE'[ProcessOutcomeDateTime] IN processdate,
CROSSFILTER('CALCTABLE'[Case ID],'FACTTABLE'[Case ID],Both)
)
If I have misunderstood your needs, please feel free to contact us with the expected output.
Best Regards,
Gao
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum
Thank you so much!
I amended
MIN ( 'CALCTABLE'[Total Errors] )
"Min" to "Sum" to get the results I wanted and it worked.
Thank you!