March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hi, can somebody help me with this.
Available data
Year-QTR | Quarter rank | usage |
2021-1 | 1 | 1021.4 |
2021-2 | 2 | 964 |
2021-3 | 3 | 1023.7 |
2021-4 | 4 | 1042.6 |
2022-1 | 5 | 1043 |
2022-2 | 6 | 1049 |
2022-3 | 7 | 1053 |
2022-4 | 8 | 1052 |
2023-1 | 9 | 1020 |
Expected result
The differnce for the first (Base) value must be blank.
Any help would be much appriciated. Thanks in advance.
Solved! Go to Solution.
@Reddy5833 Try:
Measure =
VAR __Current = SUM('Table'[usage])
VAR __CurrentQR = MAX('Table'[Quarter rank])
VAR __Previous = SUMX(FILTER(ALL('Table'),[Quarter rank] = __CurrentQR - 1),[usage])
VAR __Result = IF(__Previous = BLANK(),BLANK(),__Current - __Previous)
RETURN
__Result
Hi @Greg_Deckler, I have usage data for 5 years, (around 1500 records), the table contains date field, formateed as date data type only, I want to calculate differnce of usage between current qtr and prvs qtr (same as i asked in previos question, but based on proper date field)
I'm using below measeu to calculate prev quarter usage,
measure to calculate diff: -- works fine when i connect with date table
sample data
result when connected with date dimension
Result when not connected with date
@Reddy5833 This is because you are using CALCULATE. CALCULATE almost requires a star schema to work properly. CALCULATE has a really hard time dealing with single table data models so you get wacky results. See this video:
@Reddy5833 Try:
Measure =
VAR __Current = SUM('Table'[usage])
VAR __CurrentQR = MAX('Table'[Quarter rank])
VAR __Previous = SUMX(FILTER(ALL('Table'),[Quarter rank] = __CurrentQR - 1),[usage])
VAR __Result = IF(__Previous = BLANK(),BLANK(),__Current - __Previous)
RETURN
__Result
Hi @Greg
Hope you are doing good
The Measure you share is working fine when I have only one category, but when I have multipel categories in my dataset it is unable to find the difference between current quarter and previous quarter when I choose a category from the slicer.
But it works fine when we select all categories from slicer it is showing the over all differnce between current quarter and prev quarter.
I'm unable to use calculate function in the measure it is giving wrong values if I do so
Below is the measre you shared a while ago.
Measure = VAR __Current = SUM('Table'[usage]) VAR __CurrentQR = MAX('Table'[Quarter rank]) VAR __Previous = SUMX(FILTER(ALL('Table'),[Quarter rank] = __CurrentQR - 1),[usage]) VAR __Result = IF(__Previous = BLANK(),BLANK(),__Current - __Previous) RETURN __Result
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
124 | |
87 | |
85 | |
70 | |
51 |
User | Count |
---|---|
205 | |
153 | |
97 | |
79 | |
69 |