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
vjnvinod
Impactful Individual
Impactful Individual

Standard available hours DAX

Dear all,

here is my sample pbix

https://drive.google.com/file/d/1-rK9-gNVg2OD6TvKYv8XaGUsUBmKK0sj/view?usp=sharing

 and expected output below

Resource GPNUpdated onAttributeChargableStandard Available Hours
AE01112031010-Jun-21Time (Hours) 11 Sep 2021 - 17 Sep 202124.0040.00
AE01112031010-Jun-21Time (Hours) 11 Sep 2021 - 17 Sep 20210.000.00
AE01112031010-Jun-21Time (Hours) 11 Sep 2021 - 17 Sep 20210.000.00
AE01112031010-Jun-21Time (Hours) 11 Sep 2021 - 17 Sep 20210.000.00
AE01112031010-Jun-21Time (Hours) 11 Sep 2021 - 17 Sep 20210.000.00
AE01112031010-Jun-21Time (Hours) 11 Sep 2021 - 17 Sep 20210.000.00

 

Basically, what i need is a calculated coloumn with a logic that if the combination of coloumn Resource GPN and Attribute count is greater thn 1, thn only 1 row should show 40 and the remaining should show me output as 0 (as you can see from the above excel table)

 

is there anyway to achieve, i am not able to find any solution in the internet to get a dax code to solve this use case

1 ACCEPTED SOLUTION
v-eqin-msft
Community Support
Community Support

Hi @vjnvinod ,

 

Based on my test, there are duplicate rows with almost exactly the same value, so you need to add an Index column in Power Query firstly the identify the difference.

Eyelyn9_0-1633312348900.png

And then use the following DAX formula to create a column:

Standard Available Hours =
VAR _count =
    CALCULATE (
        COUNTROWS ( 'Mercury_Extract' ),
        ALLEXCEPT (
            Mercury_Extract,
            'Mercury_Extract'[Resource GPN],
            Mercury_Extract[Attribute]
        )
    )
VAR _first =
    MINX (
        FILTER (
            'Mercury_Extract',
            [Resource GPN] = EARLIER ( [Resource GPN] )
                && [Attribute] = EARLIER ( [Attribute] )
        ),
        [Index]
    )
RETURN
    IF (
        _count > 0,
        LOOKUPVALUE ( Mercury_Extract[Attribute], [Index], _first ),
        0
    )

 

Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-eqin-msft
Community Support
Community Support

Hi @vjnvinod ,

 

Based on my test, there are duplicate rows with almost exactly the same value, so you need to add an Index column in Power Query firstly the identify the difference.

Eyelyn9_0-1633312348900.png

And then use the following DAX formula to create a column:

Standard Available Hours =
VAR _count =
    CALCULATE (
        COUNTROWS ( 'Mercury_Extract' ),
        ALLEXCEPT (
            Mercury_Extract,
            'Mercury_Extract'[Resource GPN],
            Mercury_Extract[Attribute]
        )
    )
VAR _first =
    MINX (
        FILTER (
            'Mercury_Extract',
            [Resource GPN] = EARLIER ( [Resource GPN] )
                && [Attribute] = EARLIER ( [Attribute] )
        ),
        [Index]
    )
RETURN
    IF (
        _count > 0,
        LOOKUPVALUE ( Mercury_Extract[Attribute], [Index], _first ),
        0
    )

 

Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

vjnvinod
Impactful Individual
Impactful Individual

@amitchandak 

 

is that something you can help with?

Appears like to be a difficult one to achieve

i have also provided the sample pbix too

vjnvinod
Impactful Individual
Impactful Individual

@v-henryk-mstf 

 

Hello Microsoft community team,

 

Can you please help me with my thread?

is there anyway to achieve this?

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.