Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago

Need help in creating a visual with rows with five different calculations of a fact table

In a project where I am converting an OBIEE report to Power BI, I came across a report where : 

 

One matrix table has to be created in Power BI where there are two levels of rows, 

  1. one level is coming from a column in the Dim table which has a passive relationship with a column of a Fact table,
    2. another level is coming from another column of that Dim table which has a passive relationship with the Fact table. 
  2. And the rows are coming from 5 different calculations based on multiple columns of that Fact table.


Question is: 

1.Will the different rows be calculated columns or measures?
2. Will the rows be calculated columns or measures?
3. Which will be the measure that will be placed on the value field of the matrix table?
4. How to achieve this table?

The screen shot in OBIEE is:

 

As seen on OBIEE visualization

 

Being unable to achieve this in Power BI, I have created a SQL script (given below):

 

SELECT
tblexp1.decode, tblexp2.col2, f.month_year, d.day_key, g.geo_key,
SUM ( CASE WHEN f.NBR_RSRC_FACIL_OCCUPIED > 0 THEN f.NBR_RSRC_FACIL_CAPACITY  END) as available,
SUM ( CASE WHEN f.NBR_RSRC_FACIL_OCCUPIED > 0 THEN (f.NBR_RSRC_FACIL_CAPACITY - f.NBR_RSRC_FACIL_OCCUPIED)  END) as vacant,
SUM ( CASE WHEN f.NBR_RSRC_FACIL_OCCUPIED > 0 THEN (f.NBR_RSRC_FACIL_OCCUPIED)  END) as occupied,
count ( CASE WHEN f.NBR_RSRC_FACIL_OCCUPIED > 0 THEN (f.ID_RESOURCE)  END) as ActiveHomesWithKids,
count ( CASE WHEN f.NBR_RSRC_FACIL_OCCUPIED = 0 THEN (f.ID_RESOURCE)  END) as ActiveHomesWithOutKids
FROM shinesdm.w_dfcs_foster_homes_f f
JOIN
 (  Select distinct c.code as code, c.code_key, c.decode as decode,
    (  CASE WHEN c.Decode = 'Child Caring Institution' Then 'CCI' ELSE c.Decode END ) as col1
    From shinesdm.w_dfcs_foster_homes_f f
    Join shinesdm.w_code_tables_d c On c.code_key = f.rsrc_facil_type_key
    Join shinesdm.w_day_d d On d.day_key = f.calendar_key
    Where f.month_year like 'Jan - 2023') tblexp1
ON f.rsrc_facil_type_key = tblexp1.code_key
JOIN
    (Select distinct c.code as code, c.code_key, c.decode as decode,
    (   CASE WHEN c.code = '01' Then NULL ELSE c.code END) as col2
    From shinesdm.w_dfcs_foster_homes_f f
    Join shinesdm.w_code_tables_d c
    On c.code_key = f.rsrc_fa_home_status_key
    Join shinesdm.w_day_d d
    On d.day_key = f.calendar_key) tblexp2
ON f.rsrc_fa_home_status_key = tblexp2.code_key
JOIN shinesdm.w_day_d d on d.day_key = f.calendar_key
JOIN shinesdm.w_geo_d g on g.geo_key = f.geo_key
WHERE f.month_year like 'Jan - 2023'
GROUP BY tblexp1.decode, tblexp2.col2, f.month_year, d.day_key, g.geo_key

 

That created a visual like this with the Dim table columns i.e. (tblexp1.decode, tblexp2.col2) placed along the Row of the matrix table visualization 

And the five calculation  (available, vacant, occupied, ActiveHomesWithKids, ActiveHomesWithOutKids) placed in Values of the matrix table visualization 

 

But the users want to have the report in the following layout, as it is in OBIEE right now:

 

CCI

DFCS F/A Home

ICPC Adoptive

ICPC Foster

ICPC Relative

 

Kinship (No Payment) (DFCS Custody)

Non DFCS F/A Home              

 

 

AFA

ASA

 

 

 

 

AFA

ASA

 

Total Number of Beds Available

 

175

 

874

 

0

190

125

 

375

 

1

 

 

 

2266

               1 

41

Total Number Of Beds Vacant

208

 

1703

1

5

 

49

 

160

 

0

 

1760

1

0

Total Number Of Beds Occupied

3445

 

4597         

 

2

8

 

89

 

248

 

                               

                               

 

5073

3

 

Total Number Of Active Foster Homes with Kids

1389

 

3517         

3

7

70

 

227

 

 

3525

3

 

Number Of Active Foster Homes Without Kids

2056

 

1080

 

-1

1

 

19

21

              

1548

0

 

I do not know how to achieve this in Power BI.

 

Please help.

3 Replies

  • But the users want to have the report in the following layout, as it is in OBIEE right now

    Trying to make one tool behave like another tool is a fallacy.  If they want it to behave like OBIEE, let them use OBIEE.  Power BI uses different paradigms.

    • Anonymous's avatar
      Anonymous
      Not applicable

      I understand. But I, as a customer decided to move to Power BI from OBIEE. So, can you please suggest how to get the Power BI visual in the given layout? 

      • lbendlin's avatar
        lbendlin
        Super User

        Eliminate/fold the second matrix column hierarchy level into the first.  Create [DFCS F/A Home AFA] and [DFCS F/A Home ASA]  columns.