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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Bakhtawar
Post Patron
Post Patron

Creating variables in power bi

I have so many tables. I want to create variable .. I searched on google and found that by going Home-->new measure you will create new variable but click on this looks like we have to create in table but i dont want to create variables in table.. i want to create variable and then i want to call in KPI or in graph . . like just we do in qlik sense we simply click on variable button and then box appear and on that we create many variables without adding them in table like they are just separate from tables..

this is what i want that create variables in separate and then call them in KPI.. is that possible

like i have this

 

 

Total_Sales_Variable = 
IF ( 
    VALUES ( 'VBRK_BillingDocument_Header'[Billing Doc.currency_WAERK] ) = "USD",
    [vCurrency],
    1
) * 
CALCULATE ( 
    SUM ( 'VBRK_BillingDocument_Header'[Billing Sales Amount_NETWR] ),
    FILTER ( 
        'VBRK_BillingDocument_Header',
        'VBRK_BillingDocument_Header'[Fiscal Year] = 2016 ||
        'VBRK_BillingDocument_Header'[Fiscal Year] = 2017
    ),
    FILTER ( 
        'VBRK_BillingDocument_Header',
        'VBRK_BillingDocument_Header'[Billing Type_FKART] <> "ZG2" &&
        'VBRK_BillingDocument_Header'[Billing Type_FKART] <> "ZL2"
    )
)
4 REPLIES 4
v-frfei-msft
Community Support
Community Support

Hi @Bakhtawar ,

 

Did you mean what if parameter?

 

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

i try this but this shows an error 

 

i have this formula

Total_Sales_Variable = 
IF ( 
    VALUES (BillingDocument_Header[Billing Doc. currency_WAK] ) = "USD",
    139.2,
    1
) * 
CALCULATE ( 
    SUM (BillingDocument_Item[Sales Amount_NEWR]),
    FILTER ( 
        'Invoice_Calender',
        'Invoice_Calender'[Fiscal_Year] = 2016 &&
       'Invoice_Calender'[Fiscal_Year]  = 2017
    ),
    FILTER ( 
        'BillingDocument_Header',
        'BillingDocument_Header'[Bill Type_FKRT] <> "Z2" &&
        'BillingDocument_Header'[Bill Type_FKRT] <> "Z2"
    )
)

when i add this shows an error

MdxScript(Model) (8, 5) Calculation error in measure 'Invoice_Calender'[Total_Sales_Variable]: A table of multiple values was supplied where a single value was expected.

any help ?

Anonymous
Not applicable

@Bakhtawar  - 

First, some Power BI vocabulary:

Measure:  value that is calculated at query run-time. 

Calculated Column: value that is stored row-by-row.

Variable: value that is calculated within a Measure/Calculated Column/Calculated Table to make code easier to read and faster.

 

It looks like what you want are Measures.

To assess performance, you presumably want to compare 2 measures: The Target and the Actual.

Then, add a KPI visual and include your Target and Actual measures. You'll also need to specify a trend axis.

 


KPI.PNG

 

Cheers!

Nathan

no .. i want to create varaibles. .

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.