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
power_roboter
Frequent Visitor

Calculate in selectcolumns on all rows of a user

Hi dax experts,

 

I have a table with user log data and want to calculate the numberOfDays for the filtered users inside a selectcolumns. The problem is, that calculate(DISTINCTCOUNT('∑ Tracking Data'[Date_Key]) is always 1 for every user. It seems that calculate always refers to only one row of a user. But it must refer to all rows of a user. How can I implement this?

 

EVALUATE

DISTINCT (
SELECTCOLUMNS (
FILTER (
'∑ Tracking Data',
'∑ Tracking Data'[Application] = "product_a"
&& '∑ Tracking Data'[Userrole] = "customer"
),
"userID", '∑ Tracking Data'[userId],
"numberOfDays", calculate(DISTINCTCOUNT('∑ Tracking Data'[Date_Key]))
))

 

 

Unbenannt.PNG

 

 

 

1 ACCEPTED SOLUTION

maybe try ALLEXCEPT ( '∑ Tracking Data', '∑ Tracking Data'[Userrole] )

View solution in original post

4 REPLIES 4
harshnathani
Community Champion
Community Champion

Hi @power_roboter ,

 

Try ALL()

 

DISTINCT (
    SELECTCOLUMNS (
        FILTER (
            '∑ Tracking Data',
            '∑ Tracking Data'[Application] = "product_a"
                && '∑ Tracking Data'[Userrole] = "customer"
        ),
        "userID", '∑ Tracking Data'[userId],
        "numberOfDays", CALCULATE (
            DISTINCTCOUNT ( '∑ Tracking Data'[Date_Key] ),
            ALL ( '∑ Tracking Data' )
        )
    )
)

 

Regards,

Harsh Nathani

Appreciate with a Kudos!! (Click the Thumbs Up Button)

Did I answer your question? Mark my post as a solution!

 

This is not working. The calculation then refers to all user data, but not to the data of a (one) user.

 

Unbenannt_2.PNG

maybe try ALLEXCEPT ( '∑ Tracking Data', '∑ Tracking Data'[Userrole] )

Works perfect! Thanks!

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