Context in DAX-formules

Introductie tot DAX in Power BI

Jess Ahmet

Content Developer, DataCamp

Introductie tot context

  • Maakt dynamische analyses mogelijk: formuleresultaten veranderen met de geselecteerde data
  • Er zijn 3 typen context: rij, filter en query
Introductie tot DAX in Power BI

Introductie tot rijcontext

  • "De huidige rij"
Introductie tot DAX in Power BI

Introductie tot rijcontext

  • "De huidige rij"

Berekende kolom

  • Bevat waarden uit alle kolommen binnen de huidige rij
Introductie tot DAX in Power BI

Introductie tot rijcontext

  • "De huidige rij"

Berekende kolom

  • Bevat waarden uit alle kolommen binnen de huidige rij
Item Prijs Belasting Prijs_incl_btw
A $ 20 25% $25
B $ 45 0% $45
C $ 100 15% $115
Introductie tot DAX in Power BI

Introductie tot rijcontext

  • "De huidige rij"

Maatstaven (Measures)

  • Toepasbaar met iterator-functies die rij voor rij rekenen
  • Herkenbaar aan een X na de functienaam, bijv. SUMX()
  • Syntaxis: SUMX(<table>, <expression>)
Introductie tot DAX in Power BI

Introductie tot rijcontext

  • "De huidige rij"

Maatstaven (Measures)

  • Toepasbaar met iterator-functies die rij voor rij rekenen
  • Herkenbaar aan een X na de functienaam, bijv. SUMX()
  • Syntaxis: SUMX(<table>, <expression>)
Item Prijs Belasting Prijs_incl_btw
A $ 20 25% $25
B $ 45 0% $45
Introductie tot DAX in Power BI

Introductie tot rijcontext

  • "De huidige rij"

Maatstaven (Measures)

  • Toepasbaar met iterator-functies die rij voor rij rekenen
  • Herkenbaar aan een X na de functienaam, bijv. SUMX()
  • Syntaxis: SUMX(<table>, <expression>)
Item Prijs Belasting Prijs_met_btw
A $ 20 25% $25
B $ 45 0% $45
Totaal - - $ 70
  • Voorbeeld: SUMX(Sales, Sales[Price] + (Sales[Price] * Sales[Tax]))
Introductie tot DAX in Power BI

Introductie tot filtercontext

Filtercontext is de set filters die is toegepast vóór de berekening.

Filtercontext kun je op meerdere manieren toepassen:

  • Attributen in een rij/kolom
  • Via een slicer
  • Via het filterdeelvenster
  • In een berekende maatstaf
Introductie tot DAX in Power BI

Introductie tot filtercontext

Filtercontext is de set filters die is toegepast vóór de berekening.

Voorbeeld:

Kleur Aantal
Blauw 1.250
Groen 200
Zwart 4.000
Introductie tot DAX in Power BI

Introductie tot filtercontext

Filtercontext is de set filters die is toegepast vóór de berekening.

Voorbeeld:

Kleur Aantal
Blauw 1.250
Introductie tot DAX in Power BI

Introductie tot filtercontext

Filtercontext is de set filters die is toegepast vóór de berekening.

Voorbeeld:

Kleur Aantal
Blauw 1.250
Groen 200
Zwart 4.000
Introductie tot DAX in Power BI

Introductie tot filtercontext

Filtercontext is de set filters die is toegepast vóór de berekening.

Voorbeeld:

Sokken Schoenen T-shirt
Blauw 200 800 250
Groen 90 10 100
Zwart 2.000 800 1.200
Introductie tot DAX in Power BI

Introductie tot filtercontext

Filtercontext is de set filters die is toegepast vóór de berekening.

Voorbeeld:

Sokken
Blauw 200
Introductie tot DAX in Power BI

CALCULATE-functie

  • Syntaxis: CALCULATE(<expression>[, <filter1> [, <filter2> [, …]]])
    • Expressie: een maatstaf of berekening om te evalueren. Moet één waarde teruggeven.
    • Filters:
      • Filters moeten evalueren tot een tabel
      • Filters mogen niet met elkaar conflicteren
        • Sales[City]="London", Sales[Country] <> "United Kingdom"
      • CALCULATE()-filters overschrijven altijd filters uit de visual
  • Voorbeeld: CALCULATE(SUM(Sales), Sales[Region]="EMEA")
Introductie tot DAX in Power BI

Laten we oefenen!

Introductie tot DAX in Power BI

Preparing Video For Download...