Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
hello everyone!
I have the following problem, I can't figure out how to solve it.
I have 2 tables Cost and Rent, both linked via a calendar table
I need to sum the values from Cost and Rent only when they are present in the Cost table, otherwise 0,
a simple calculation works fine for single month selected,
Date | Cost |
01-01-2023 | 100 |
01-03-2023 | 150 |
Date | Rent |
01-01-2023 | 50 |
01-02-2023 | 100 |
01-03-2023 | 150 |
Solved! Go to Solution.
Try this version
Total costs =
CALCULATE (
SUMX (
DISTINCT ( Costs[Date] ),
VAR CurrentDate = Costs[Date]
RETURN
CALCULATE ( [Costs] + [Rents], TREATAS ( { CurrentDate }, 'Calendar'[Date] ) )
),
'Acc'[Code] = "160"
)
From the behaviour we have seen I would guess that there is some rogue data in Costs which is causing a date from that table to be picked up when it shouldn't be.
If you identify a particular period when the data is wrong then examine all the Costs data for that period, regardless of other filters. That might shed some light on where the issue is.
Good news,
I managed to get the correct value using SUMX(ValuesGEO[City], your code).
Their videos are always must-watch.
Glad you solved it.
it worked!
thanks a lot, do you by any chance know what was the issue ? why simple filter in calculate didn't work ?
I'm nowhere near sure on this, but I think its to do with the way that queries are executed to produce a matrix, particularly a matrix with a hierarchy on the roles. Several queries are produced and then combined, and my guess is that at some level the filter we were generating resulted in an empty table, or a blank value, and that led to its being ignored for some parts of the calculation.
When you had the filter on the visual then that would be applied to all of the different queries and that's why it worked.
i tried it previously, for some reason it doesn't help
User | Count |
---|---|
54 | |
22 | |
19 | |
16 | |
11 |
User | Count |
---|---|
81 | |
55 | |
39 | |
20 | |
12 |