Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
mtomova
Frequent Visitor

How to use SWITCH & CALCULATE to calculate from one table, by applying filter from a second table

Hi All!

 

I am trying to create a calculated measure by using SWITCH & CALCULATE to cover multiple statuses.

The information I use is separated in two different tables, there is a connection between the tables, 

however, my CALCULATE is not returning any result.

 

The two tables are HH and Measures.

For one HH(Household) I can have multiple entries in the Measures table. The two tables are related by unique reference number for each Household.

 

Based on a SWITCH statement that is being true, if a Household Ops status = X
Then count number of referals in Measures table, if criteria met.

 

My Calculation returns nothing:

 

SWITCH(TRUE(),
FIRSTNONBLANK('HH'[Ops Status], 1) = "Allocated to Installer (Measures)",
CALCULATE(COUNT('Measure'[SURVEYMEASUREVIEW::Reference]), 'Measure'[Measure Ops Status] = "Allocated to Installer (Measures)"),

FIRSTNONBLANK('HH'[Ops Status], 1) = "Allocated to Installer (Measures)",

CALCULATE(COUNT('Measure'[SURVEYMEASUREVIEW::Reference]), 'Measure'[Measure Ops Status] = "Awaiting technical survey (Measures)"),

etc...

)
2 REPLIES 2
mtomova
Frequent Visitor

Hello, @amitchandak !
Apologies for the late response!
HH table:

ReferenceOps Status
100601Awaiting Whole House Plan
100606Retrofit Design Approved (Household)
100608Allocated to Installer (Household)
100613Awaiting Whole House Plan
100621Awaiting Inspection
100622Allocated to Installer (Household)
100631Allocated to Installer (Household)
100635Allocated to Installer (Household)
100638

Retrofit Design Approved (Household)

 

Measures table:

ReferenceMeasure Ops Status
100606Retrofit Design Approved (Measures)
100606Retrofit Design Approved (Measures)
100606Measure Billed
100606Measure Billed
100606Retrofit Design Approved (Measures)
100608Allocated to Installer (Measures)
100608Retrofit Design Approved (Measures)
100608Measure Billed
100608Measure Billed
100621Measure Billed
100621Measure Billed
100621Measure Billed
100621Measure Billed
100622Allocated to Installer (Measures)
100622Measure Billed
100622Measure Billed
100631Allocated to Installer (Measures)
100631Allocated to Installer (Measures)
100631Measure Billed
100631Measure Billed
100631Measure Billed
100631Retrofit Design Approved (Measures)
100635Allocated to Installer (Measures)
100635Allocated to Installer (Measures)
100635Measure Billed
100635Measure Billed
100638Measure Billed
100638Measure Billed
100638Retrofit Design Approved (Measures)

 

 

I am not sure if there is a way to upload these tables as files.
I could not find how to do it, apologies if the format is not user friendly!

amitchandak
Super User
Super User

@mtomova ,
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.