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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
dandamudisanjay
Regular Visitor

Help with DAX

Hi Experts, 

 

Hope you all are doing well. 

 

I'm hoping to get some help with the following issue. 

 

We have two tables, table 1 and table 2 connected with 1-N relation  with fields as below

 

Table 1

ID
Category
User



Table 2

KPI
User

 

Users have different KPI's and KPI is linked to category. we need to display total of ID's once we select the user so the relevant KPI (in text) gets selected behind the scenes. 

 

Please could you share any ideas?

 

Thanks in advance. 

Sanjay

7 REPLIES 7
SivaMani
Resident Rockstar
Resident Rockstar

@dandamudisanjay, Is your requirement to count the number of KPIs by User?

Hi @SivaMani ,

 

I'm looking to get total of ID's from table 1 which meets the following conditions. 

 

 

- if KPI = "Target1" then count of ID's where category is "category 1"

- if KPI = "Target2" then count of ID's where category is "category 2"

- else, total count of ID's

Fsciencetech
Helper III
Helper III

Hi @dandamudisanjay 

Hope you are good.

 

If you have two table, so why you are not making relationship between them with "Many to one"

 

you may get the related KPI's .

If it was not relavent, share few records for both table, will reply soon on that.

 

Hi @Fsciencetech 

 

I'm looking to get total of ID's from table 1 which meets the following conditions. 

 

- if KPI = "Target1" then count of ID's where category is "category 1"

- if KPI = "Target2" then count of ID's where category is "category 2"

- else, total count of ID's

@dandamudisanjay,

Try this in a measure,

Count of Id =
VAR __KPI =
    MAX ( Table2[KPI] )
RETURN
    SWITCH (
        TRUE (),
        __KPI = "Target1", CALCULATE ( COUNT ( Table1[Id] ), Table1[Category] = "category 1" ),
        __KPI = "Target2", CALCULATE ( COUNT ( Table1[Id] ), Table1[Category] = "category 2" ),
        COUNT ( Table1[Id] )
    )

 Note: You may need to change the cross-filtering as bidirectional 

Thanks @SivaMani . 

 

I have created the measure on table 2. It is showing stats as expected. Problem I'm now stuck with is, I have a stacked bar chart with User(from table 2) as Axis and ID(from table 1) as total values. I also have a filter for User from table 2 as slicer. 

 

Whenever I select user in slicer (from table 2), the total ID comes up correctly which represents relevant KPI with link to category but the stacked bar chart is not reflecting the relevant ID's for the category and KPI. It is showing count of all ID's. 

 

Please any suggestion on this?

@dandamudisanjay,

 

Can you try the user column from Table 1?

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors