Forum Discussion

Patrick_Rumya's avatar
Patrick_Rumya
New Member
7 months ago
Solved

Problem with the filter on a comparison chart whose data comes from merged tables

I'm creating a report with several charts using Power BI. In my main table or query, I have two columns (besoins_baseline and besoin_pdm) that I'd like to compare based on the number of times a value...
  • MFelix's avatar
    7 months ago

    Hi Patrick_Rumya ,

     

    For this you need to create a table with the besoins unique values and then use two dax measures on top of your data without the group in Power Query that will count the values.

     

    This calculations can be done with or without relationship between your table and the besoins table. Below see an example of calculations without relationship:

     

     

    Baseline Values = CALCULATE(COUNTROWS('Fact Table'), TREATAS(VALUES(Besoins[Besoins]), 'Fact Table'[Besoins Baseline]))
    
    PDM Values = CALCULATE(COUNTROWS('Fact Table'), TREATAS(VALUES( 'Besoins'[Besoins]), 'Fact Table'[Besoins PDM]))

     

    Final Result:

     

    The disconnected table must be used has the Y-axis, in this example and the measures has values, any filter you apply to the report will be applied to this calculation.

     

    If you want you can make relationships between the tables and then use a similar sintax to this one:

     

     

    Baseline Values = CALCULATE(COUNTROWS('Fact Table'), USERELATIONSHIP(Besoins[Besoins], 'Fact Table'[Besoins Baseline]))
    
    PDM Values = CALCULATE(COUNTROWS('Fact Table'), USERELATIONSHIP( 'Besoins'[Besoins], 'Fact Table'[Besoins PDM]))
    

    Result is the same.