Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Try your skills in the Power BI Dataviz World Championship! Round one ends June 26. Join now

Reply
SaraFtg
Frequent Visitor

Calculated column changes value in report

Hi,

 

First, English is not my mother tounge, so I hope I make myself understood :).

 

I'm quite new att Power BI and I'm struggeling with a calculated column and the outcoming result in my report.

So, my company want's to follow up on how "old" a member is when they pay there membership fee (number of years as a member), and I have one column that calculates that:

 

SaraFtg_3-1627296986146.png

 

MemberYears =
Var vContractMemberFrom = RELATED(Customer[Contract Member From])
Var vMinPeriodStartingDate = MINX(RELATEDTABLE(Sales), Sales[Member Period Starting Date])
Var vMemberYears =
IF(
ISBLANK(vContractMemberFrom),
-1,
ROUNDDOWN(YEARFRAC(vContractMemberFrom, vMinPeriodStartingDate, 1), 0)
)
RETURN
IF(NOT ISBLANK(vMinPeriodStartingDate), vMemberYears)

 

Why we have both "Missing" and "(Blank)" is because an invoice may refer to either a membership fee or other sales. 

 

Second, I'm grouping these values with SWITCH in an other column:

 

SaraFtg_4-1627297033177.png

 

MemberYears (group) =
SWITCH(
TRUE(),
'Sales Headers'[MemberYears] = -1, "Missing",
ISBLANK('Sales Headers'[MemberYears]), "(Blank)",
'Sales Headers'[MemberYears] = 0, "0",
'Sales Headers'[MemberYears] = 1, "1",
'Sales Headers'[MemberYears] = 2, "2",
'Sales Headers'[MemberYears] = 3, "3",
'Sales Headers'[MemberYears] = 4, "4",
'Sales Headers'[MemberYears] = 5, "5",
'Sales Headers'[MemberYears] >= 6 && 'Sales Headers'[MemberYears] < 11, "6-10",
'Sales Headers'[MemberYears] >= 11 && 'Sales Headers'[MemberYears] < 21, "11-20",
'Sales Headers'[MemberYears] >= 21 && 'Sales Headers'[MemberYears] < 51, "21-50",
'Sales Headers'[MemberYears] >= 51 && 'Sales Headers'[MemberYears] < 1000, "50+"
)
 
I get the expected result in my datamodel
 
SaraFtg_0-1627296477858.png

 

but in my report, all the items with value "-1", that should be grouped as "Missing", is converted to "50+" Why is that?

 

SaraFtg_1-1627296666924.png

I've tried to add && <> -1 on the last row, but that doesn't work either. How is it possible that the datamodel and the report shows different values? Any one who has an idea or solution?

 

Thanks in advance!

 

 

1 ACCEPTED SOLUTION

Hi @selimovd,

 

After some more digging I found that empty cells in date column in my Customer table returned 30/12/1899, so when I calculated MemberYear the result became 120 years.

 

Instead of IF(ISBLANK(vContractMemberFrom),-1,... I tried IF(vContractMemberFrom = 0,-1,... and now it seems to work fine.

 
Thanks for taking your time to respond to my issue!

View solution in original post

6 REPLIES 6
v-henryk-mstf
Community Support
Community Support

Hi @SaraFtg ,

 

After reviewing your question, it seems that it has been resolved. You can mark the correct response as the standard answer to help the other members find it more quickly.

 

If there is still confusion, you can describe your problem in detail and provide relevant data and information. I will answer you as soon as possible.


Best Regards,
Henry

 

selimovd
Most Valuable Professional
Most Valuable Professional

Hey @SaraFtg ,

 

can you check if Document No 765663 has multiple rows in your data?

If you chose MAX as aggregation for MemberYears (group) it could be that it would show the MAX of the rows and if that Document No has multiple rows that would explain it.

 

Also try to set the aggregation in the visual to "Don't summarize":

selimovd_0-1627297903702.png

 

Like this all rows should be shown for sure.

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

Hm, when adding the MembertYear-column (also set to Don't summarize) to my visual the problem seems to be that -1 is set to 120 (resulting in that it's grouped as "50+"). So - question is why that is happening?

 

SaraFtg_0-1627300254764.png

 

selimovd
Most Valuable Professional
Most Valuable Professional

Hey @SaraFtg ,

 

can you share the file? It would be a lot easier to take a look at the file itself.

 

Best regards

Denis

Hi @selimovd,

 

After some more digging I found that empty cells in date column in my Customer table returned 30/12/1899, so when I calculated MemberYear the result became 120 years.

 

Instead of IF(ISBLANK(vContractMemberFrom),-1,... I tried IF(vContractMemberFrom = 0,-1,... and now it seems to work fine.

 
Thanks for taking your time to respond to my issue!

Hi @selimovd,

 

Thanks for you reply!

 

Document No appears in three different tables, and on several rows in two of them, but not in the table where this calculation is made. 

 

The aggregation is set to Don't summarize, these are the options I have

 

SaraFtg_0-1627298715425.png

 

Best regards,

Sara

 

Helpful resources

Announcements
Fabric Data Days is here Carousel

Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.