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

Crossjoins behaving unexpectedly

Hi,

 

I have a problem trying to roll up values in Power BI. What I am trying to accomplish:

 

- I have a list of hours booked on a certain day by a certain person in multiple lines.

- Roll up the lines by date and person into a single number of hours on that day

- Check a slicer value and see if the amount of hours is smaller than that value

- If so, return 1 else return 0

 

What I have currently tried:

Result = SUMX(CROSSJOIN(values([Name]),VALUES([Date]), IF(calculate(SUM([Hours])<SELECTEDVALUE(MySlicer),1,0))

 

The result is below:

screen.PNG

 

I also added the comparison values. As you can see they are flawless. However, the result for June 10 is off. This should evaluate to 0. Can anyone help me with what is going wrong here? Because I am at a total loss.

1 ACCEPTED SOLUTION
SemG
Frequent Visitor

Found the solution. The problem is caused by a well known problem of comparing two floating point numbers. Both numbers need to be explicitly rounded to 2 digits for it to work. A night of sleep can do a lot of good. Thanks for responding!

View solution in original post

4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hi,

 

Why not simply use

 

=IF(calculate(SUM([Hours])<SELECTEDVALUE(MySlicer),1,0)

 

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi,

 

Thanks for responding. Because the grand total evaluates to 0 if you just use IF. Also, I just checked an it had the same problem. Certain values that clearly need to get evaluated to 0 get evaluated to 1. Anyone?

SemG
Frequent Visitor

Found the solution. The problem is caused by a well known problem of comparing two floating point numbers. Both numbers need to be explicitly rounded to 2 digits for it to work. A night of sleep can do a lot of good. Thanks for responding!

@SemG,

 

Glad to hear that. You may help accept solution. Your contribution is highly appreciated.

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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