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
Analitika
Post Prodigy
Post Prodigy

Adding lines to visual in Power BI

Hi,

 

I would like to ask how to add lines by year. For example Lines number depends on filtered years. For example, we select two years (2022, 2021) and visual appears two lines according to these years. Now I have line which is accumulated values depends on selected years. So how to make that will be separate years lines in visual?

 

Current visual looks like this:

Analitika_0-1665066191780.png

 

2 REPLIES 2
v-chenwuz-msft
Community Support
Community Support

Hi @Analitika ,

 

Maybe you can try what if parameter with fields parameter.

vchenwuzmsft_0-1665123921541.png

 

Create measures for each year and use fields parameter for the line-y-axis of the chart.

Result:

vchenwuzmsft_1-1665124236563.gif

 

Pbix in the end you can refer.

Best Regards

Community Support Team _ chenwu zhu

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Ok but if I have this measure for line current:

Pardavimai santykis_h = 
var metu_uzdarymo_pozymis=[ABC_Metu_uzdarymo_ZU0_KOD]
var valandos= CALCULATE([kiekis_h], all('Sas kod unik BRIDGE'[POZYMIAI Veiklu (Excel AUTO)]),all('Sas kod unik BRIDGE'[Sąskaitos pavadinimas]), all('Sas kod unik BRIDGE'[Pajamu sanaudu vaizdavimas (PAVADINIMAI)]),ALL('DBA view_DidknObj'[DID_NR]),ALL('DBA view_DidknObj'[DID_DAT]),ALL('DBA view_DidknObj'[OBJ_KOD]),ALL('DBA view_DidknObj'[Saskaitos numeris]),ALL('DBA klient_tiekejai'[kli_pav]))
/*var savikaina= sumx(FILTER('DBA view_DidknObj', RELATED('Sas kod unik BRIDGE'[POZYMIAI Veiklu (Excel AUTO)])="Savikaina"&&Find(metu_uzdarymo_pozymis,'DBA view_DidknObj'[ZU0_KOD],,0)=0), 'DBA view_DidknObj'[SUM_DEB]-'DBA view_DidknObj'[SUM_CRE])*/
return


if([kiekis_h]=BLANK(),"",DIVIDE([_2_1_1_Pardavimai (priklauso nuo vienetų pasirinkimo)],valandos))

Visual type is line and clustered column chart. So how change in my case? How I should change my measure in this case?

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.