Forum Discussion

krimyr's avatar
krimyr
Frequent Visitor
2 years ago

How to count multiple dims away?

Hi,

 

I have a Fact table.

This is connected to a DimDate with the Date field, working great..

... and also connected to a lot of other Dim tables, working great..

 

I have connected my Fact to DimTable1 -> DimTable2 -> DimTable3 -> DimTable4.

On DimTable4 I want to count how many there is where Type=1, Type=2 etc..

 

I have a COUNTROWS(DimTable4) in my Fact, and filtering on the type. No matter what I do, it only shows me the total amount of rows.

 

What do I have to change, and why?

 

Thanks in advance.

 

6 Replies

  • krimyr your presentation seems confusing, I guess dim tables doesn't have a relationship with each other?

     

    Which table has the type column?

    • krimyr's avatar
      krimyr
      Frequent Visitor

      I am sorry! I thought it was clear.

       

      Fact has a relationship to DimTable1. (1 to many)
      DimTable1 has a relationship to DimTable2 (1 to many)
      DimTable2 has a relationship to DimTable3 (1 to many)

      DimTable3 has a relationship to DimTable4 (1 to many)


      DimTable4 has Type which I want to count based on Type=1,2,3 etc.

  • krimyr if you create a measure that countrows from dimtable4 and you visualize using type (from same table), it should give the result you are looking for or maybe I'm missing something.

     

    Count = COUNTROWS ( DimTable4 ) 
  • krimyr's avatar
    krimyr
    Frequent Visitor

    You are right, now it works. I have been working on this too many hours. I of course must have done something different. Thanks

  • krimyr's avatar
    krimyr
    Frequent Visitor

     

    CountDimRows = COUNTROWS(DimTable4)

     

    DimTalbe2[Name] as ROWS
    DimTable4[Type] as COLUMNS
    CountDimRows as VALUES

     

     

    Shows as I want it.

     


    If I filter on the Fact column that has relationship to DimTable1, it wont affect the result.
    If I filter on the DimTable1 column that has relationship to DimTable2, it wont affect the result.
    If I filter on the DimTable2 column that has relationship to DimTable3, it does affect the result as it should.

     

    Why is that?

    It seems that there's relationships missing, but its connected, and I can't see the problem.

  • krimyr see below:

     

    If I filter on the Fact column that has relationship to DimTable1, it wont affect the result. this will not, since fact table doesn't filter dimension table. There are ways to work with this but with your current relationship it will not.

     

    If I filter on the DimTable1 column that has relationship to DimTable2, it wont affect the result. If dim table1 has relationship dim table 2 (1 to many) then it should work. Can you share relationship diagram?