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
vkomarag
Helper III
Helper III

Can't we create 2 measures out of a measure and a column based on two measures.

Hi All,

 

I have the below data

 

 

IDyearquestionrating
12015q11
22015q13
32015q14
42015q12
12016q11
22016q12
32016q15
42016q14
12017q15
22017q14
32017q15

 

 

I have a measure calculated based on some rating column(say some customized formula) : Qfactor

Now I create two measure based on Qfactor

 

PREV_YEAR=CALCULATE(QFACTOR,FILTER(SHEET1,SHEET1[YEAR]="2015")

CURRYEAR=CALCULATE(QFACTOR,FILTER(SHEET1,SHEET1[YEAR]="2016")

 

Now i have to calculate  one indicator column(not measure; because i need to relate this indiactor to another source)

Indicator=if(curr_year>prev_year,2,if(curr_year<prev_year,1,0))-------------------------

 

Here is my problem.I end up in circular dependency when i create indicator column. I can create measure and absolutely no problem but i cant create a relationship to another source(we can create only columns)..

 

I am working on this for the past couple of days. Can anyone please help.

 

Thanks

KVB

1 ACCEPTED SOLUTION

Hi @vkomarag,

 

If I understand you correctly, you should be able to follow steps below to get your expected result.

 

1. Use the formula below to create a new calculate column in your table.

Qfactor = 
VAR currentYear = Sheet1[year]
RETURN
    DIVIDE (
        (
            COUNTX (
                FILTER (
                    ALL ( 'Sheet1' ),
                    ( 'Sheet1'[Rating] = 4
                        || 'Sheet1'[Rating] = 5 )
                        && Sheet1[year] = currentYear
                ),
                'Sheet1'[Rating]
            )
                - COUNTX (
                    FILTER (
                        ALL ( 'Sheet1' ),
                        ( 'Sheet1'[Rating] = 2
                            || 'Sheet1'[Rating] = 1 )
                            && Sheet1[year] = currentYear
                    ),
                    'Sheet1'[Rating]
                )
        ),
        COUNTX (
            FILTER ( ALL ( 'Sheet1' ), Sheet1[year] = currentYear ),
            'Sheet1'[Rating]
        )
    )

2. Then you should be able to use the formula below to create a new calculate column for YTD_Indicator. Smiley Happy

YTD_Indicator = 
VAR PREV_Qfactor =
    CALCULATE (
        MAX ( Sheet1[Qfactor] ),
        FILTER ( ALL ( Sheet1 ), Sheet1[year] = EARLIER ( Sheet1[year] ) - 1 )
    )
VAR CURR_Qfactor = Sheet1[Qfactor]
RETURN
    IF (
        CURR_Qfactor > PREV_Qfactor,
        "Up",
        IF ( CURR_Qfactor < PREV_Qfactor, "Down" )
    )

c1.PNG

 

Regards

View solution in original post

9 REPLIES 9
Greg_Deckler
Super User
Super User

You should see if you can create calculated columns that duplicate your measures and base your final Indicator column on those columns instead of the measures to avoid circular dependencies. 

 

You can still have your measures that you could use in visuals and such. 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler

 

First of all, I cant create 2 columns. There itself i am getting circular depndency. That's the reason i create measures for those 2 columns.

Hi @vkomarag,

 

Could you post your real table structures(including all the formulas you're using) with some sample data and your expected result? So that we can better assist on this issue. 

 

It's better that you can also share a sample pbix file which can reproduce the issue. You can upload it to OneDrive or Dropbox and post the link here. Do mask sensitive data before uploading. Smiley Happy

 

Regards

Hi @v-ljerr-msft

 

Data is already provided in the very first notification.

 

Qfactor=DIVIDE((COUNTX(FILTER('Sheet1','Sheet1'[Rating]=4||'Sheet1'[Rating]=5),'Sheet1'[Rating]) - COUNTX(FILTER('Sheet1','Sheet1'[Rating]=2||'Sheet1'[Rating]=1),'Sheet1'[Rating])),COUNTX('Sheet1','Sheet1'[Rating]))  --Measure

 

PREV_Qfactor=CALCULATE([QMeasure],FILTER(Sheet1,Sheet1[year]="2015"))  --- Measure

 

CURR_Qfactor=CALCULATE([QMeasure],FILTER(Sheet1,Sheet1[year]="2016")) --Measure

 

YTD_Indicator=IF(CURR_Qfactor>PREV_Qfactor,"Up",IF(CURR_Qfactor<PREV_Qfactor,"Down"))  -- This should be a column.Here i am getting circular dependency.

 

I cannot create as a measure because i need to relate this indicator column to another source Indicator

 

Indicator source looks like below

 

Ind_Name  Image url

Up                 <<<<url showing up arrow>>

Down            <<<<url showing down arrow>>

 

If i create the YTD_Indicator as a measure . A measure cannot be create in a relationship.

 

Hope you understood my problem.

 

Let me know if any workaround..Finally i need to show up image instead of Up and Down.

 

Thanks

KVB

 

Hi @vkomarag,

 

If I understand you correctly, you should be able to follow steps below to get your expected result.

 

1. Use the formula below to create a new calculate column in your table.

Qfactor = 
VAR currentYear = Sheet1[year]
RETURN
    DIVIDE (
        (
            COUNTX (
                FILTER (
                    ALL ( 'Sheet1' ),
                    ( 'Sheet1'[Rating] = 4
                        || 'Sheet1'[Rating] = 5 )
                        && Sheet1[year] = currentYear
                ),
                'Sheet1'[Rating]
            )
                - COUNTX (
                    FILTER (
                        ALL ( 'Sheet1' ),
                        ( 'Sheet1'[Rating] = 2
                            || 'Sheet1'[Rating] = 1 )
                            && Sheet1[year] = currentYear
                    ),
                    'Sheet1'[Rating]
                )
        ),
        COUNTX (
            FILTER ( ALL ( 'Sheet1' ), Sheet1[year] = currentYear ),
            'Sheet1'[Rating]
        )
    )

2. Then you should be able to use the formula below to create a new calculate column for YTD_Indicator. Smiley Happy

YTD_Indicator = 
VAR PREV_Qfactor =
    CALCULATE (
        MAX ( Sheet1[Qfactor] ),
        FILTER ( ALL ( Sheet1 ), Sheet1[year] = EARLIER ( Sheet1[year] ) - 1 )
    )
VAR CURR_Qfactor = Sheet1[Qfactor]
RETURN
    IF (
        CURR_Qfactor > PREV_Qfactor,
        "Up",
        IF ( CURR_Qfactor < PREV_Qfactor, "Down" )
    )

c1.PNG

 

Regards

HI @v-ljerr-msft

 

I have ended up in measure showing the statc value for any question grouped. Any pointers?

@v-ljerr-msft

 

I have tried the given one.It worked. About to create another columns or measures based on this Qfactor.

 

Hopefully it should work. 

 

Thanks again for your time and effort.

CURR_Qfactor should be the recent year and calculate similar to PREV_Qfactor.I can modify the formula.Not an issue.Let me try and get back to you.

OK, then you're probably going to have to learn how to do it in M code then so that when it gets into the model, you already have the column that you need to perform the link on. However, that may in and of itself prove problematic. Going to need to see all of the formulas and such for things like QFACTOR, etc.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.