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

Be 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

Reply
alex12432
New Member

recreating matrix as measure with calculated column

HI there,

 

I'm in quiet a pickle, I appreciate any help
I'm using a powerBI shared Dataset and I don't have the power query options; I was wondering if it's possible to recreate a matrix using a measure since measures are the only thing I can use in this case; 

my data is as follow: it rapresents people from comapnies enrolled in training courses and I'd like to know if a company is a recurring customer or not.

alex12432_0-1676979499037.png

I would like to create a matrix (counting the number of participant by year) with a calculated column, is it possible to do it only using measures? the calculated column would be a field with Yes or NO based if a company is a returning customer:

alex12432_1-1676979774935.png

the logic of the returning would be:
- if a company has at least 1 person enrolled in 2022 and none in previous years = YES

- if a company has at least 1 person enrolled in any other year and not in 2022 = NO
- if a company has at least 1 person enrolled in previous years and in 2022 = YES

 

I appreciate any help, thanks

3 REPLIES 3
tamerj1
Super User
Super User

Hi @alex12432 

please use a matrix visual, place  Company in the rows and Year in the columns, activate the total column and place the following measure in the values of the matrix 

=
VAR NormalResult =
DISTINCTCOUNT ( 'Table'[Person] )
VAR MaxYear = 2022
VAR MaxYearCount =
CALCULATE ( DISTINCTCOUNT ( 'Table'[Person] ), 'Date'[Year] = MaxYear )
VAR PreviousYearsSales =
CALCULATE ( DISTINCTCOUNT ( 'Table'[Person] ), 'Date'[Year] < MaxYear )
RETURN
IF (
HASONEVALUE ( 'Date'[Year] ),
NormalResult,
SWITCH (
TRUE (),
MaxYearCount = BLANK (), "NO",
PreviousYearsSales = BLANK (), "NEW",
"YES"
)
)

tamerj1
Super User
Super User

Hi @alex12432 

not through a calculated column but a solution to this problem is possible. However, the provided description of "Returning Customers" is not clear. Please provide proper and clear definition of "Returning Customers". 

Hi @tamerj1

I Really appreciate the help

 

in this case customers are companies and values rapresent people from those companies enrolled in training programs through the years;
A returning customer is a company with at least 1 person enrolled in 2022 and at least 1 person in any of the 2 yers before:

alex12432_0-1676993073155.png

I've created a little table, hopefully will clear any doubts around what I'm trying to create

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.