cancel
Showing results for 
Search instead for 
Did you mean: 
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
2022 Release Wave 1 760x460.png

2022 Release Wave 1 Plan

Power Platform release plan for the 2022 release wave 1 describes all new features releasing from April 2022 through September 2022.

Power BI December 2021 Update_carousel 768x460.jpg

Check it Out!

Click here to read more about the December 2021 Updates!

Jan 2022 Dev Camp 768x460 copy.png

Power BI Dev Camp- January 27th, 2022

Mark your calendars and join us for our next Power BI Dev Camp!

Top Solution Authors