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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
usomaraju
Helper II
Helper II

Get the distinct values from few columns based on the ID

Hi, 

Could someone help me on getting the dax formula 

Here is my table data

idnamestartdateenddateno of daysstages
200abc3/13/20203/13/20200stg1
200abc3/13/20203/13/20200stg2
202xyz3/18/20203/19/202015stg2
202xyz3/13/20203/19/202015stg1
202xyz3/12/20203/27/202015stg3
2071234/30/20205/1/20206stg1
2071234/30/20205/6/20206stg2

 

the no of days is calculated by the difference between the startdate for the ID and the end date for the same id 

eg: for 202, the startdate is 3/12/2020 and enddate is 3/27/2020 .So the difference is 15 days.

and i need the result like below based on id

200abc3/13/20203/13/20200stg2
202xyz3/12/20203/27/202015stg3
2071234/30/20205/6/20206stg2

once i get the above table, i need to merge this result with the datetable provided by the powerbi , can someone please provide suggestions, how can we do to get the monthly report based on calender days from the datetable not based on the dates available in the existing table.

 

 

1 ACCEPTED SOLUTION
JustJan
Responsive Resident
Responsive Resident

Hi @usomaraju

 

Providing the measure is setup correctly, the reason that you don't see the expected values is because the table contains data columns that are not the same for an ID.

 

What if you create a table with just ID and the measure, then you should get one line per id with the max completed date for the ID.

If you now add you column 'startdate', which has multiple values per id, you will that you will get multiple line per ID. That is why use a measure to show the earliest (min) startdate per id instead of the actual column.

 

Hope this helps

 

-Jan

 

 

 

View solution in original post

3 REPLIES 3
JustJan
Responsive Resident
Responsive Resident

Hi @usomaraju,

 

The first part of your question is pretty straightforward, most of the measures can be created via the Quick Measure Dialog:

 

2020-06-21 21_12_38-Window.png

 

Duration
=[Last enddate max per id] - [First startdate min per id]
First startdate min per id
= MINX (
    KEEPFILTERS ( VALUES ( 'data'[id] ) ),
    CALCULATE ( MIN ( 'data'[startdate] ) )
)
Last enddate max per id
= MAXX (
    KEEPFILTERS ( VALUES ( 'data'[id] ) ),
    CALCULATE ( MAX ( 'data'[enddate] ) )
)
Last stage per id
= MAXX (
    KEEPFILTERS ( VALUES ( 'data'[id] ) ),
    CALCULATE ( MAX ( 'data'[stages] ) )
)
  

 

Not sure what you mean exactly with the month report based on calendar days.

- Jan

 

 

hi jan , i have tried the quick measure for to get the max completed date based on the ID, which is not providing the values correctly.

 

see here the Quick measure columne displaying the same results as completed column.

 

i need for each id, one row with mx completed date which is for id 163, the valuse is 2/28/2020.

 

same for 166, it is 3/3/2020.

Capturedax5.PNG

JustJan
Responsive Resident
Responsive Resident

Hi @usomaraju

 

Providing the measure is setup correctly, the reason that you don't see the expected values is because the table contains data columns that are not the same for an ID.

 

What if you create a table with just ID and the measure, then you should get one line per id with the max completed date for the ID.

If you now add you column 'startdate', which has multiple values per id, you will that you will get multiple line per ID. That is why use a measure to show the earliest (min) startdate per id instead of the actual column.

 

Hope this helps

 

-Jan

 

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors